Changing how isql executes SQL

isql is typically used as a troubleshooting tool. For example, if you are having an issue with your ODBC back end, isql will help you identify whether the problem lies with your application (do you still get the same problem in isql as you get in your application?) or elsewhere.

isql's -e flag enables you to change how isql executes SQL. Doing this enables you to simulate how your application behaves in this regard.

To find out which method your application uses to execute SQL:

  1. Add these lines to /etc/odbcinst.ini:
    [ODBC]
    Trace=Yes
    TraceFile=/tmp/sql.log
  2. Run a query in your application.
  3. Open /tmp/sql.log in a text editor. If the log file contains SQLPrepare your application uses this ODBC API. Otherwise, it uses SQLExecDirect.
  4. In /etc/odbcinst.ini, turn off ODBC tracing:
    [ODBC]
    Trace=No
    TraceFile=/tmp/sql.log

By default, isql uses SQLPrepare and SQLExecute to execute SQL statements.

To use SQLExecDirect instead, include the -e flag on the command line:

 /usr/local/easysoft/unixODBC/bin/isql.sh -e -v SQLSERVER_SAMPLE
SQL> select mycol from mytable