Discussion:
[fpc-pascal] is this a bug?
duilio foschi via fpc-pascal
2021-06-02 11:00:12 UTC
Permalink
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
Dennis Lee Bieber via fpc-pascal
2021-06-02 17:04:14 UTC
Permalink
On Wed, 2 Jun 2021 13:00:12 +0200, duilio foschi via fpc-pascal
Post by duilio foschi via fpc-pascal
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
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.
Did Delphi use an auto-commit mode on database connections -- meaning
it closed transactions on each query?
--
Wulfraed Dennis Lee Bieber AF6VN
***@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freep
duilio foschi via fpc-pascal
2021-06-03 11:17:59 UTC
Permalink
Post by Dennis Lee Bieber via fpc-pascal
Did Delphi use an auto-commit mode
I did some tests in old Delphi5: an exception is raised if I try to modify
the sql text of an open query.

This would help a lot in fpc, too.

Either the query is automatically closed or an exception should be raised.

The current behaviour of TQuery is error prone IMHO.

On Thu, Jun 3, 2021 at 10:32 AM Dennis Lee Bieber via fpc-pascal <
Post by Dennis Lee Bieber via fpc-pascal
On Wed, 2 Jun 2021 13:00:12 +0200, duilio foschi via fpc-pascal
Post by duilio foschi via fpc-pascal
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
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.
Did Delphi use an auto-commit mode on database connections -- meaning
it closed transactions on each query?
--
Wulfraed Dennis Lee Bieber AF6VN
http://wlfraed.microdiversity.freeddns.org/
_______________________________________________
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Loading...