Recent

Author Topic: sql log file with sql statement and parameter value  (Read 382 times)

Packs

  • Sr. Member
  • ****
  • Posts: 368
sql log file with sql statement and parameter value
« on: November 30, 2024, 11:43:40 am »
I have lot of query with parameters .

can I log inside file with sql statement and it's parameter value .

how to achieve this.

CharlyTango

  • Jr. Member
  • **
  • Posts: 90
Re: sql log file with sql statement and parameter value
« Reply #1 on: November 30, 2024, 09:01:22 pm »
Yes, you can ;-)

Unfortunately, my crystal ball is currently being serviced and is therefore out of order.

For a qualified answer, it would be nice if you could also specify which Lazarus version, which FPC version you are using and which access path you have chosen (SQLDB, ZEOS, other) and perhaps also against which SQL database you are querying.
All this could have an influence on the answer.

Some SQL databases have a monitor option to see incoming and outgoing SQL statements.

For SQLDB, TSQLConnector.OnLog is your friend and for ZEOS, TZSQLMonitor might be helpful.
For other access paths ask the vendor ;-)

Lazarus stable, Win32/64

Zvoni

  • Hero Member
  • *****
  • Posts: 2741
Re: sql log file with sql statement and parameter value
« Reply #2 on: December 02, 2024, 09:06:27 am »
Yes, you can ;-)
Quoting Obama?  :P

Quote
Unfortunately, my crystal ball is currently being serviced and is therefore out of order.
I broke my ball last week....

Quote
Some SQL databases have a monitor option to see incoming and outgoing SQL statements.
SQLite has "expanded SQL" function, which does exactly that (returning the "parsed" SQL-Statement with the parameterized Values),
which i even managed to get to work (with a Class-Helper)

EDIT: Have to amend my "got to work": It involved some "edit" inside sqlite3conn, since we need the Cursor (=TSqlite3Cursor), and this type is under the implementation-section (for whatever reason), so it won't work with Class helper and/or derived class

Anyone know why it's under implementation in sqlite3conn, when its ancestor (TSQLCursor) is under Interface in sqldb?
« Last Edit: December 02, 2024, 10:03:32 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018