Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-06

is this a bug?

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

duilio foschi

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

Reply by email

duilio foschi
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 <

Show quoted text 32 lines
wrote: On Wed, 2 Jun 2021 13:00:12 +0200, duilio foschi via fpc-pascal declaimed the following: >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/ _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email