Pervasive SQL (PSQL) capture SQL statements

Is there a way to capture SQL statements sent to a PSQL 11 database? Can this be done in PCC?
Who is Participating?
Bill BachConnect With a Mentor PresidentCommented:
If you want to capture SQL statements coming from existing applications, then the query plan is probably the best option. However this can grab queries from all users at the same time, and the data must be parsed with either the included Query Plan Viewer (one at a time) or the third-party ParseQPF tool.

If you don't want to affect all users of this DSN, and if the queries are coming from remote workstations (not running locally), then another third-party tool called SQL Interceptor would work for you. It relies on the WinPcap library which must be installed separately, but it can quickly get you the statements from all users (if run on the server) or one user (if run on the workstation).

Beyond this, yopu can install the third-party WireShark, capture all network traffic to TCP port 1583 on the server, and parse the packets yourself.
Check on the Query Plan option.  
It's fully documented at

The easiest way is to use the SET QRYPLAN statement:

To create a query plan
Execute SET QRYPLAN = on to turn on the creation of a query plan.
Execute the SET QRYPLANOUTPUT statement and specify the location and name of the query plan file.
See Query Plan Settings.
Execute an SQL SELECT, INSERT, UPDATE, or DELETE statement (which creates its corresponding query plan).
Execute SET QRYPLAN = off to turn off the creation of query plans.
PerfishentAuthor Commented:
Will this capture SQL statements coming from an application and not just from PCC itself?
If the application issues a SET QRYPLAN, it'll capture them.  
There was a way to set a registry setting but I haven't tried it recently.  Here's the details:
The settings that affect whether the relational engine gathers query plan
information are QryPlan and QryPlanOutput.  These settings are associated with
the DSN, and the DSN information is saved in the registry, or in a file,
depending on the type of DSN.  I will only describe how to set these settings
for system and user DSNs, which are stored in the registry.  The process for
setting these for a file DSN is similar.

For a system DSN, look in the following section of the registry:

For a user DSN, look in the following section of the registry:

In the appropriate section, find and select the name of  the DSN for which you
want to gather query plan information.  On the right side of the editor, you
will see all of the settings for the DSN, similar to the information in Figure

Figure 1

Add two string values for the DSN as shown in Table 1.
Registry Setting Value
QryPlan 1
QryPlanOutput <directory and file name to place query plan information>
Table 1

Notice that the QryPlanOutput value is not the directory where you want the
information placed, but the directory and the file name.  You can use any
extension you want, but I suggest using an extension of "QPF", as this is the
default extension that the query plan viewer uses.

NOTE: You can disable query plan generation by setting QryPlan=0.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.