How to get statements, that are sent by TOracledataset to Oracle

janr

Member
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
 
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.
 
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

 
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
 
Back
Top