Passing String Values with Embedded Quotes
Suppose the database value for which you are entering a comparison value contains embedded single or double quotes, as for example:
"Big John's" Barbecue
Suppose the where clause is specified in the report as:
where $wherevar
You want to specify a value for the variable so that Report‑Writer produces the following SQL query:
where clientname='"Big John''s" Barbecue'
Follow this procedure:
1. Determine how the value appears in the database:
"Big John's" Barbecue
2. Enclose the string value in quotes that are appropriate for your query language (single quotes in SQL). Dereference any embedded quotes (including apostrophes) according to the rules of your query language (in SQL, precede a single quote or apostrophe with another single quote):
'"Big John''s" Barbecue'
3. Enclose the entire valuestring within single quotes to identify it to Report‑Writer as a string. Dereference any embedded single quotes within this string by preceding each single quote with another single quote. This includes any single quotes (or apostrophes) from the original value, as well as those required by your query language in the previous step.
'clientname=''"Big John''''s" Barbecue'''
4. Enclose the entire parameter within parentheses. If the parameter contains any characters treated specially by your operating system (such as parentheses in Windows NT and UNIX or slashes in VMS), enclose the entire parameter within double quotes and escape any embedded double quotes to pass them through the operating system.
Windows:
report accounting receivables "(wherevar=
'clientname=''\"Big John''''s\" Barbecue"''')"
UNIX:
report accounting receivables "(wherevar=
'clientname=''\"Big John''''s\" Barbecue"''')"
VMS:
report accounting receivables "(wherevar=
'clientname=''""Big John''''s"" Barbecue"''')"
Note for QUEL Users
To specify a value for the variable so that Report‑Writer produces the following QUEL query:
where clientname="\"Big John's\" Barbeque"
Follow this procedure:
1. Determine how the value appears in the database:
"Big John's" Barbeque
2. Enclose the string value in quotes that are appropriate for your query language (double quotes in QUEL). Dereference any embedded quotes according to the rules of your query language (in QUEL, precede a double quote with a backslash):
"\"Big John's\" Barbeque"
3. Enclose the entire valuestring within single quotes to identify it to Report‑Writer as a string. Dereference any embedded single quotes (or apostrophes) within this string by preceding each one with a single quote.
'clientname="\"Big John''s\" Barbeque"'
4. Enclose the entire parameter within parentheses. If the parameter contains any characters treated specially by your operating system (such as parentheses in Windows NT and UNIX or slashes in VMS), enclose the entire parameter within double quotes and escape any embedded double quotes to pass them through the operating system.
Windows:
report accounting receivables "(wherevar= 'clientname=\"\\\"Big John''s\\\"Barbeque\"')"
UNIX:
report accounting receivables "(wherevar= 'clientname=\"\\\"Big John''s\\\"Barbeque\"')"
VMS:
report accounting receivables "(wherevar= 'clientname=""\""Big John''s\""Barbeque""')"