TRACESQL - trace SQL calls

SYNOPSIS

<TRACESQL on|off|N>


DESCRIPTION
The TRACESQL directive sets an integer value that controls the tracing of SQL calls made by a script. (Setting it to "on" or "off" is the equivalent of 1 or 0, respectively.) The lowest 4 bits are interpreted as a value from 0 to 15 that control SQL statement printing, with each value printing everything at lower values too:

  • 0: no tracing

  • 1: prints a message for every SQL statement, containing the full statement with its parameters

  • 2: prints the entirety of parameters instead of just the first few characters

  • 3: parameters are single-quote-escaped for cut-and-paste to a tsql command line for testing (not recommended for production use)

  • 4: spaces/comments/newlines are not stripped

The remaining higher bits are taken as flags to control other SQL tracing messages. Thus the following values can be bitwise ORed into the value:

  • 0x00010: SQL cache debug messages will be printed

  • 0x00020: print the database during cache trace messages

  • 0x00040: print Texis API calls

  • 0x00080: print process ID as well

  • 0x00100: do not replace non-ASCII bytes in parameters with "."

  • 0x00200: print compiled SQL expression cache messages

  • 0x00400: print compiled SQL expression at compile or open

  • 0x00800: print compiled SQL expression before evaluation

  • 0x01000: print compiled SQL expression after evaluation

  • 0x02000: print SQL expression if non-compilable

  • 0x04000: print SQL expression source before parameters parsed

  • 0x08000: print SQL expression source after parameters parsed

  • 0x10000: print SQL expression value after evaluation

As it is a directive, <TRACESQL> must appear before the first function in the script. SQL tracing can also be enabled at run time with the sqlcp function (here), which overrides this directive, and on the command line with the -tracesql option. Note that tracing functionality and values may change in future releases, as this is a debugging directive. Values 0x04000, 0x08000 and 0x10000 were added in version 7.06.1517417000 20180131.


EXAMPLE

<TRACESQL on>

<a name=main>
  <if $del eq "y">
    <sql "delete from books where id = $id"></sql>
  <else>
    <sql "update books set Text=$txt where id = $id"></sql>
  </if>
</a>


CAVEATS
The <TRACESQL> directive was added in version 3.0.947100000 20000105.

Setting <TRACESQL> to 2 or higher can produce large messages for statements like the insertion of text fields.


SEE ALSO
sqlcp, -tracesql command line option


Copyright © Thunderstone Software     Last updated: Oct 24 2023
Copyright © 2024 Thunderstone Software LLC. All rights reserved.