I'm unsig ODAC (5.10.4.12) TOraScript and load the script at runtime. I assign a value to a macro but when I execute the script the macro is not substituted.
Sample Script:
CREATE OR REPLACE DIRECTORY AS &P1
/
Sample Code:
for i := 0 to OraScript.Macros.Count - 1 do
begin
MacroName := 'P' + IntToStr(i + 1);
OraScript.FindMacro(MacroName).Value := MainFrm.Macro;
end;
Application.ProcessMessages;
// execute the script
try
OraScript.Execute;
except
on e: Exception do
begin
MainFrm.AddMessage(e.Message);
end;
end;
The documentation states theat the substitution occurs "In time of opening Query..."
There is no Open for TOraScript and when I execute the script the substitution does not occur and I get an oracle error becuase it can't create a directory named &P1.
How can I force the macro substitution at runtime?
John
TOraScript and Macros
Re: TOraScript and Macros
I found out that it was the Oracle statment that was in error, however I have connected an OraQuery to capture the individual statements to echo the command to the user and the Text of the OraQuery.SQL.Text still shows the Macro not the substituted text.
Is there a wa to update the Query with the macro substitution?
John
Is there a wa to update the Query with the macro substitution?
John
Use the following code:
Code: Select all
var
SQL: string;
...
SQL := OraQuery.SQL.Text;
OraQuery.Macros.Expand(SQL);