TDAParam - Dynamic Query

TDAParam - Dynamic Query

Postby owsion » Thu 27 Oct 2005 07:30

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
owsion
 
Posts: 4
Joined: Mon 17 Oct 2005 09:39

Postby Ikar » Mon 31 Oct 2005 15:08

> params.CreateParam(ftUnknown,'USER_ID',ptUnknown);

In MyDAC, parameters are created automatically. To avoid the problem just comment this line.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby owsion » Mon 31 Oct 2005 15:25

Thanks Ikar,

you're right
owsion
 
Posts: 4
Joined: Mon 17 Oct 2005 09:39


Return to MySQL Data Access Components