Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can i see actual query sent through SQLEXEC
Message
From
07/03/2017 05:46:14
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Database:
MS SQL Server
Miscellaneous
Thread ID:
01648813
Message ID:
01648819
Views:
52
>Hi Jaime,
>
>You can turn on ODBC tracing.
>
>
>#define SQL_OPT_TRACE                   104
>#define SQL_OPT_TRACEFILE               105
>
>#define SQL_IS_INTEGER							(-6)
>
>DECLARE integer SQLSetConnectAttr in odbc32.dll integer, integer, string @, integer
>DECLARE integer SQLSetConnectAttr in odbc32.dll AS SQLSetConnectAttrI integer, integer, integer, integer
>
>LOCAL lihdbc,liHODBC,liLen,liPom
>liLen=0
>lihdbc=SQLSTRINGCONNECT(".....")
>
>liHODBC=SQLGETPROP(lihdbc,"ODBChdbc")
>
>lcPom="E:\trace.log"
>=SQLSetConnectAttr(liHODBC, SQL_OPT_TRACEFILE, @lcPom, LEN(lcPom))
>
>liPom=1
>=SQLSetConnectAttrI(liHODBC, SQL_OPT_TRACE, liPom, SQL_IS_INTEGER)
>
>=SQLEXEC(lihdbc,"SELECT XX002,XX003 FROM XXT004I WHERE XX000=2")
>
>
>liPom=0
>=SQLSetConnectAttrI(liHODBC, SQL_OPT_TRACE, liPom, SQL_IS_INTEGER)
>
>=SQLDISCONNECT(lihdbc)
>
>
>
>
>MartinaJ
>
>>Hi
>>Assuming i have the following:
>>myVar = "test"
>>mySql = "select * from myTable where someField=?myVar"
>>=sqlExec( Handle, mySql )
>>
>>
>>How can i see the actual query sent to the backend DB? I need this to build an auditlog. Afterwards, i will cursortoxml() the resulting sqlresult cursor for the saved response, but i need the actual values sent...
>>
>>Many thanks
>>Jaime

I think that Jaime wanted to log the actual value of the parameters. It that is so, the ODBC trace won't do because it does not register that information. Nice and useful snippet, nevertheless.
----------------------------------
António Tavares Lopes
Previous
Reply
Map
View

Click here to load this message in the networking platform