Print Thread
How to get statements, that are sent by TOracledataset to Oracle
#42823 11/29/11 11:26 AM
Joined: Nov 2011
Posts: 2
J
janr Offline OP
Member
OP Offline
Member
J
Joined: Nov 2011
Posts: 2
I'm using the TOracleDataset.Debug method because I'm interested in the update, insert and delete statements, that are sent to Oracle. However I don't want these statements shown in a pop-up window, but I want to have them in a String or TSTrings variable, so that I can re-route them to a log-file.
Is this Possible?
Regards, Jan

Re: How to get statements, that are sent by TOracledataset to Oracle
janr #42830 11/30/11 10:33 AM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
You can use the global LogActivity event in the Oracle unit for this:

var LogActivity: procedure(ComponentType: Integer; AObject: TObject; Flag, Info: Integer; const Description, SQL, ResultMessage: string; Variables: TVariables; Parameters: TStrings; StartTime: LongInt);

This event is triggered before and after a database access function is called, so that you can log or monitor these events.

The ComponentType parameter indicates what type of component has triggered the action: ckSession, ckQuery, ckDataSet, ckPackage, ckEvent, ckLOBLocator, ckObject, ckReference, ckScript, ckLoader, or ckQueue.

The AObject parameter is the object that has triggered the action (e.g. a TOracleSession instance, a TOracleQuery instance, and so on).

The Flag parameter can be afStart when an activity starts, afEnd when an activity ends, or afSingle when an Activity does not have a start/end moment.

The Info parameter is for internal use only.

The Description parameter is a single line description of the activity. For example 'Session.Logon as scott@detroit', or 'Query.Execute'.

The SQL parameter contains the SQL text, if applicable.

The ResultMessage contains an error message, or is empty if the activity succeeded.

The Variables parameter is a list of bind variables, before (Flag = akStart) or after (Flag = akEnd) the activity.

The Parameters parameter is for internal use only.

The StartTime parameter is the start time of the activity in milliseconds, and can be used at the end of the activity (Flag = akEnd) to calculate the elapsed time of the activity.


Marco Kalter
Allround Automations
Re: How to get statements, that are sent by TOracledataset to Oracle
Marco Kalter #42840 12/01/11 07:06 AM
Joined: Nov 2011
Posts: 2
J
janr Offline OP
Member
OP Offline
Member
J
Joined: Nov 2011
Posts: 2
Thanks, Marco, this really helped me.
Regards, Jan

Re: How to get statements, that are sent by TOracledataset to Oracle
janr #48983 05/08/14 10:29 AM
Joined: May 2003
Posts: 113
Moenchengladbach; Germany
Member
Offline
Member
Joined: May 2003
Posts: 113
Moenchengladbach; Germany
Hi Marco,

Using this entry because it is actually the same topic.
Was trying this in C++ but how can I declare that:

did the following

LogActivity = &LogDBActivity;
or
Oracle::LogActivity = &LogDBActivity;
same problem

And the methode is
void __fastcall TForm2::LogDBActivity(int ComponentType, System::TObject* AObject,
int Flag, int Info,
const System::UnicodeString Description,
const System::UnicodeString SQL,
const System::UnicodeString ResultMessage,
Oracletypes::TVariables* Variables,
System::Classes::TStrings* Parameters,
int StartTime)

but with that I got the following error:
[BCC32 Error] EventCasting.cpp(20): E2034 Cannot convert 'void (_fastcall * (_closure )(int,TObject *,int,int,const UnicodeString,const UnicodeString,const UnicodeString,TVariables *,TStrings *,int))(int,TObject *,int,int,const UnicodeString,const UnicodeString,const UnicodeString,TVariables *,TStrings *,int)' to 'void (_fastcall *)(int,TObject *,int,int,const UnicodeString,const UnicodeString,const UnicodeString,TVariables *,TStrings *,int)'
Full parser context
EventCasting.cpp(16): parsing: _fastcall TForm2::TForm2(TComponent *)


Actually I have no clue, how I can call a Global Event here...
Can you or somebody help out here!


thx a lot


Re: How to get statements, that are sent by TOracledataset to Oracle
stef #48993 05/09/14 08:09 AM
Joined: May 2003
Posts: 113
Moenchengladbach; Germany
Member
Offline
Member
Joined: May 2003
Posts: 113
Moenchengladbach; Germany
Hi,

I found the answer.
The package is not a VCL package, so you cannot declare this methode in your own class. Declare it global


Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.086s Queries: 14 (0.021s) Memory: 2.5207 MB (Peak: 3.0428 MB) Data Comp: Off Server Time: 2024-05-18 06:15:29 UTC
Valid HTML 5 and Valid CSS