Server Side SQL logging capabilities were enhanced in
OpenEdge 11.7 :
SET PRO_SERVER LOG [ ON | OFF ]
[ WITH ({ STATEMENT, INOUT, QUERY_PLAN })]
[[AND]
WITH LEVEL 1|LEVEL 2|LEVEL 3|LEVEL 4];
For further information Refer to Article
SQL-92: How to turn SQL statement logging on and off? To capture, extract and replay SQL prepared statements:The following are provided in the attachment to this Article:
000091419_sql_parse_and_replay.zip1. enableSqlLogging.bat or enableSqlLogging.sh
- Edit the sqlexp command to connect to the database under investigation with the correct credentials
- Enables SQL server side logging:
SET PRO_SERVER LOG ON WITH (STATEMENT, INOUT, QUERY_PLAN) AND WITH LEVEL 3;
2. disableSqlLogging.bat or disableSqlLogging.sh
- Edit the sqlexp command to connect to the database under investigation with the correct credentials
- Disables SQL server side logging:
SET PRO_SERVER LOG OFF;
3. sqlExtract.pyA python script to parse SQL Statements captured with Server Side SQL logging LEVEL 3 and INOUT
Log files can be concatenated into a single file when more than one needs to be processed
(Windows): $ copy SQL_server*.log all_SQL_server_file_content.txt
(Linux/Unix): $ cat SQL_server*.log > all_SQL_server_file_content.txt
To run the extraction process execute the python script directly:
$ python.exe sqlExtract.py SQL_server_3_20190811_021004_A.log outputScript.txt
Alternatively use sqlExtract.bat (Windows) or sqlExtract.sh (Linux/Unix) provided as sample scripts:
- If the location of the Python executable is not in the Environment PATH, these scripts need to be edited in order that python.exe can be found.
$ sqlExtract.bat SQL_server_3_20190811_021004_A.log outputScript.txt
$ ./sqlExtract.sh SQL_server_3_20190811_021004_A.log outputScript.txt
SQL Statement Output (
outputScript.txt)
Non prepared SQL statements will each be written on a separate text line in the python output file.
Prepared SQL statements, will be presented as follows in the python script output file:
SELECT * FROM pub.tableName WHERE someColumn = ? AND someOtherColumn = ?
[0]: = (11)
[1]: = (2018)
4. SqlBatchExecParamQueries.bat and SqlBatchExecParamQueries.sh
- To replay the SQL (prepared) statements in a controlled environment for further analysis
- Optionally to only execute SQL SELECT statements, use -onlySqlSelects
$ SqlBatchExecParamQueries.bat -user sysprogress -password sysprogress -db testdb -S 5555 -H localhost -infile pythonScriptOutput.txt
$ SqlBatchExecParamQueries.sh -user sysprogress -password sysprogress -db testdb -S 5555 -H localhost -infile pythonScriptOutput.txt -onlySqlSelects