Overriding prepare sql

nicofari

Member²
I would like to create a component derived from
TOracleDataset.
I need to override the standard prepare sql
method, which should perform a kind of "macro substitution", to insert the schema owner of
db objects (which is known runtime only).
so the developer write an sql like this:
select *
from %OWNER%.Employee

and the component substitutes the macro with
the correct schema name.
In TQuery it is possible to overrider PrepareSQL (if i remember correctly..)
Is there something similar in DOA (we use 3.4.6)
TIA
Nicola
 
It is not possible to override a prepare method, but for the purpose you described you can use a substitution variable:
Code:
select *
from :OWNER.Employee
You can set the :OWNER variable at runtime before executing the statement or opening/refreshing the dataset.

------------------
Marco Kalter
Allround Automations
 
Thank you for your reply.
I was aware of this solution but IMHO
the component based solution would be far better..
In this way this behaviour will be encapsulated
and nobody of the developers should remember to set this variable.
Less code around and more centralized...
What a pity!
Thanks again
 
For a TOracleDataSet you could override DoBeforeOpen (from TDataSet) and set the owner variable.

------------------
Marco Kalter
Allround Automations
 
Back
Top