| Home | Previous Lesson: Logging SQL Statement Execution Next Lesson: Tracing and Performance Analysis |
It is also possible to get details about ODBC driver's API calls. You need to provide ConnectOption parameter to the DBParm option. At run-time, you can do as follows:
SQLCA.dbParm="ConnectString='DSN=product',ConnectOption= 'SQL_OPT_TRACE,SQL_OPT_TRACE_ON;SQL_OPT_TRACEFILE, C:\workdir\prododbc.log'" |
Please note that, the above file entries are in a single line. To debug in the development environment, you need to set the same in the database painter. Invoke the database painter, select File/Connect/Setup and select "product" option in the dialog box and click Edit button. Type the following for the DbParm prompt:
ConnectString='DSN=product',ConnectOption= 'SQL_OPT_TRACE,SQL_OPT_TRACE_ON;SQL_OPT_TRACEFILE, C:\workdir\prododbc.log' |
Again, all the above lines are on one line. Run the application and exit the application. If you open c:\workdir\prododbc.log file, you will see the ODBC calls PowerBuilder sent to the database.
The following are some of the commands given, when running through a procedure similar to the one above:
SQLError(henv004E3B7C, hdbc004D5120, hstmt00000000, szSqlState,
pfNativeError, szErrorMsg, 513, pcbErrorMsg);
SQLDriverConnect(hdbc004D542C, hwnd000001A4, "DSN=product", -3,
szConnStrOut, 513, pcbConnStrOut, 1);
SQLGetInfo(hdbc004D542C, 2, rgbInfoValue, 256, pcbInfoValue);
SQLGetInfo(hdbc004D542C, 17, rgbInfoValue, 256, pcbInfoValue);
SQLGetConnectOption(hdbc004D542C, 102, pvParam);
SQLGetInfo(hdbc004D542C, 8, rgbInfoValue, 4, pcbInfoValue);
SQLGetInfo(hdbc004D542C, 43, rgbInfoValue, 4, pcbInfoValue);
SQLAllocStmt(hdbc004D542C, phstmt004D573C);
SQLGetTypeInfo(hstmt004D573C, 0);
SQLGetFunctions(hdbc004D542C, 59, pfExists);
SQLSetStmtOption(hstmt004D573C, 9, 00000010);
SQLBindCol(hstmt004D573C, 1, 1, rgbValue, 130, pcbValue);
SQLBindCol(hstmt004D573C, 2, 5, rgbValue, 2, pcbValue);
SQLExtendedFetch(hstmt004D573C, 1, 1, pcrow, rgfRowStatus);
SQLFreeStmt(hstmt004D573C, 1);
SQLAllocStmt(hdbc004D542C, phstmt004D573C);
SQLTables(hstmt004D573C, "(null)", 0, "dba", 3, "pbcattbl", -3,
"(null)", 0);
SQLFetch(hstmt004D573C);
SQLFreeStmt(hstmt004D573C, 1);
Do you realize how much PowerBuilder works behind the scenes ? Go back to the database painter, and set back the DbParm option to its original value:
ConnectString='DSN=product'
If you don't do this, PowerBuilder logs all those ODBC API calls, in turn making the application to run slowly.
| Home | Previous Lesson: Logging SQL Statement Execution Next Lesson: Tracing and Performance Analysis |