[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Quotes '''' ''''''' '''''''''' ''''''' ???????? @$%*#@#$



good suggestion, like that, I have fought with the quote thing before!

-----Original Message-----
From: James Womeldorf [mailto:jwomeldo@FASTENAL.COM]
Sent: Friday, January 04, 2002 1:40 PM
To: SQR-USERS@list.iex.net
Subject: Quotes '''' ''''''' '''''''''' ''''''' ???????? @$%*#@#$


We have all seen the lines of code where there are seemingly uncountable
quotes strung together in an attempt to get a quote imbedded into a
string.
To those of you who find that method unsettling I suggest the following:

Place the following line in the Setup section of your SQR.
#define Quote ''''

Then the following code:
let $Country = 'USA'
let $Query_Restriction = 'and B.COUNTRY = ' || {Quote} || $Country ||
{Quote}

will set $Query_Restriction equal to

and B.COUNTRY = 'USA'


This allows a substitution in a begin-select such as the following to
work:

where A.FAS_BRANCH5 = B.FAS_BRANCH5
and C.business_unit = A.FAS_BRANCH5
[$Query_Restriction]

which the begin-select then sees as:

where A.FAS_BRANCH5 = B.FAS_BRANCH5
and C.business_unit = A.FAS_BRANCH5
and B.COUNTRY = 'USA'


There are a couple benefits to using #define over setting a variable
equal
to a quote.
First, it cannot be accidently altered in your SQR.  An especially
valuable
feature if someone else works on your code someday.
Second, you can use {Quote} anywhere in your SQR, even in local
procedures
where a global variable would have to be referenced using the beloved $_
syntax.


Happy New Year!

Jim Womeldorf
Programmer/Analyst
Fastenal Company
jwomeldo@fastenal.com
(507) 453-8250