Page 1 of 1

TDAParam - Dynamic Query

Posted: Thu 27 Oct 2005 07:30
by owsion
Hello,

I've to build dynamic queries (ie not defined with the designer).

Do you have any example?

By my side I have an exception by execution:
EAssertionFailed, AssertionFailure
\MyDac\Source\MySqlStmt.pas, line436


Here an example of my definition:

Query_Current_User := TMyQuery.Create(Owner);
with Query_Current_User do
begin
Connection := Orasession_aktiv;
SQL.Text := 'SELECT'+
' *'+
' FROM'+
' DFATAI.USER_TAI_V'+
' WHERE' +
' DFATAI.USER_TAI_V.USER_ID = :USER_ID';
UniDirectional := True;
params.CreateParam(ftUnknown,'USER_ID',ptUnknown);
end;


And the call which fails:

with DataModule_Main.Query_Current_User do
begin
ParamByName('USER_ID').AsString := str;
Active := false;
Prepare;
====> Active := true;


The same if I set the FieldType and the ParamType


THx for your help

Posted: Mon 31 Oct 2005 15:08
by Ikar
> params.CreateParam(ftUnknown,'USER_ID',ptUnknown);

In MyDAC, parameters are created automatically. To avoid the problem just comment this line.

Posted: Mon 31 Oct 2005 15:25
by owsion
Thanks Ikar,

you're right