duilio foschi via fpc-pascal
2021-06-02 11:00:12 UTC
I am using FPC v. 3.2.0 on both linux and windows.
I use Firebird as a database (not sure that this is important).
Say you write
var
AConnection:TIBConnection;
AQuery:TSQLQuery;
ATran:TSQLTransaction;
begin
// create the components...
// open a database...
// prepare a first query...
ATran.SQLConnection := AConnection;
AQuery.SQLConnection := AConnection;
AQuery.Transaction := ATran;
AQuery.SQL.Text:=
' select 1 '+
' from tb_dpt '+
' where cod_dpt=:deviceId ';
// assign parameters...
AQuery.Open;
// this query returns 1
// ...
// other code here...
// ...
// start a new query
AQuery.SQL.Text:=
' select id_log '+
' from InsertIntoA_LOG( '+
' :ACTION , '+
' :USERNAME , '+
' :MAC , '+
' :ATEXT) ';
// prepare the query...
// assign parameters...
AQuery.Open;
// a GUID is expected here as a result.
Instead, the query returns 1! GULP!
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
The query uses the old SQL! No error is raised when I assign the new
parameters!
In order to get the expected results, I have to explicitly close the query
before re-assigning AQuery.SQL.Text .
I am sure that this did not happen in Delphi.
The compiler should forbid the query to be reassigned when open, or it
should authomatically close it then reassign it
Or at least an error should be raised when I try to assign say parameter
:ACTION is the 2nd query...
Not sure about the right path to take, but this behaviour brought me alread
a lot of hair-pulling :)
Peppe Polpo
I use Firebird as a database (not sure that this is important).
Say you write
var
AConnection:TIBConnection;
AQuery:TSQLQuery;
ATran:TSQLTransaction;
begin
// create the components...
// open a database...
// prepare a first query...
ATran.SQLConnection := AConnection;
AQuery.SQLConnection := AConnection;
AQuery.Transaction := ATran;
AQuery.SQL.Text:=
' select 1 '+
' from tb_dpt '+
' where cod_dpt=:deviceId ';
// assign parameters...
AQuery.Open;
// this query returns 1
// ...
// other code here...
// ...
// start a new query
AQuery.SQL.Text:=
' select id_log '+
' from InsertIntoA_LOG( '+
' :ACTION , '+
' :USERNAME , '+
' :MAC , '+
' :ATEXT) ';
// prepare the query...
// assign parameters...
AQuery.Open;
// a GUID is expected here as a result.
Instead, the query returns 1! GULP!
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
The query uses the old SQL! No error is raised when I assign the new
parameters!
In order to get the expected results, I have to explicitly close the query
before re-assigning AQuery.SQL.Text .
I am sure that this did not happen in Delphi.
The compiler should forbid the query to be reassigned when open, or it
should authomatically close it then reassign it
Or at least an error should be raised when I try to assign say parameter
:ACTION is the 2nd query...
Not sure about the right path to take, but this behaviour brought me alread
a lot of hair-pulling :)
Peppe Polpo