Alberto Tosetto, M.D. <[email protected]> wrote:
>I am having a problem with the odbc command on Stata 8.0. When I use
>the exec("...") option in the odbc load command, everything works fine
>provided that the SQL WHERE statement does not address VARCHAR values.
>For instance, if I try the following SQL statement
>
>SELECT * FROM MYTABLE, WHERE GENDER="F"
>
>Stata gives me back the following message: table() or exec() is required
The short answer is to use single quotes for any quoted value in your SQL
statement.
SELECT * FROM MYTABLE, WHERE GENDER='F'
Most ODBC Drivers, and the SQL servers they connect to, actually prefer single
quotes within SQL commands. All SQL servers we have tested take both single
and double as interchangeable. The Stata command line parser, however, does
not identify double quotes as valid syntax at this time so you will be required
to use single quotes.
In the near future Stata will most likely either 1) support double quotes in
a way that is compatible with all SQL servers, or 2) display a better error
message if the Stata parser doesn't support double quotes.
--Kevin
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/