Using the SQL statement trace utility
SQL statement tracing
A separate database trace utility lets you add date and time
entries to a log file for each SQL statement issued to the database,
along with the syntax of the SQL statement. By default, this utility
saves all log entries to a file named PBTRSSQL.log in
the current Windows directory. You can change the log file name
in the Database section of the PB.INI file
in the same way you change the trace output file name for the main
database trace utility:
|
1 |
[database] |
|
1 |
DBTraceFile=c:myApplication racesql.log |
You start the SQL statement trace utility in PowerScript code
by invoking the driver for the DBMS that you want to use with a
TRS modifier. You set the driver in the DBMS property of a connection
object. For example, for the default SQLCA connection object, if
you wanted to use ODBC with SQL tracing, you would code the following:
|
1 |
SQLCA.DBMS="TRS ODBC" |
Server-side timestamps
Server-side timestamps can be used instead of client-side
timestamps if the connecting PowerBuilder database driver supports
the DBI_GET_SERVER_TIME command type.
Currently, server-side timestamps are available for the SYC, SYJ,
and ODBC (PBSYC, PBSYJ, and PBODB) drivers.
PBTRS100.DLL obtains the date and time
from the server only once during the database connection processing.
Each time a new timestamp needs to be generated, it determines the
number of milliseconds that have transpired since the connection
was established and computes the new server-side date and time by
adding the elapsed interval to the initial connection timestamp
obtained from the server.
Log file headers
Output to the log file is always appended. For ease of reading,
the PBTRS100.DLL produces a banner inside the
log file each time a new database connection is established. The
banner lists the date and time of the database connection using
the system clock on the client workstation. The DBParms for the
database connection are listed immediately under the banner. If
a server timestamp is used for subsequent entries in the log file,
the statement “Using timestamp from DBMS server” is
entered immediately under the DBParm listings.
When you are running an application with a database trace
utility, one of the DBParm values should include the DisableBind
parameter. You should set DisableBind to 1. Otherwise the syntax
that is logged in the trace output file will contain parameter markers
instead of human-readable values.
The following figure shows a banner from a trace file that
uses a client-side timestamp in the banner itself, and server-side
timestamps elsewhere: