Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFDConnection.ExecSQL Bug?



Permlink Replies: 3 - Last Post: Jul 8, 2014 7:56 AM Last Post By: Dmitry Arefiev
Robert Holler

Posts: 6
Registered: 5/26/98
TFDConnection.ExecSQL Bug?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2014 8:17 AM
When calling TFDConnection.ExecSQL with Params for the 1. time (as log as the CommandText changes),
the first param (maybe all PK params) gets passed as 0/Null.
Tested under Firebird V2.5 and XE6 Update 1, also "visible" in FireDAC-Monitor

procedure Test_FireDAC.ExecSQL_Bug;
var C: TFDCustomConnection;
begin
// Get Connection
C := FDManager.FindConnection(ConnectionNameGDB);
C.Open;
// Drop Test Table
try
C.ExecSQL('DROP TABLE TT');
except end;
// Create Test Table
C.ExecSQL('CREATE TABLE TT (ID INTEGER, ID2 INTEGER, CONSTRAINT TT_ID PRIMARY KEY (ID))');

// C.ExecSQL('UPDATE TT SET ID=? WHERE 1=2', [1]); // when uncommenting this line, the following INSERT queries are working (because the CommandText changed)?!

// 1. ExecSQL passes wron Param Value
C.ExecSQL('INSERT INTO TT (ID,ID2) VALUES (?,?)', [1, 11]); // 1. Param (1) gets passed as 0, ID gets inserted as 0
C.ExecSQL('INSERT INTO TT (ID,ID2) VALUES (?,?)', [2, 22]); // 1. Param (2) gets passed as 0 -> INSERT fails with Key Violation because ID gets inserted as 0 again

end;

Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: TFDConnection.ExecSQL Bug?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2014 4:41 AM   in response to: Robert Holler in response to: Robert Holler
Use ":name" instead of "?" as parameter markers.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Robert Holler

Posts: 6
Registered: 5/26/98
Re: TFDConnection.ExecSQL Bug?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 8, 2014 5:32 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Will this become fixed in XE6 Update 2 or are unnamed params deprecated ?

We are about to port to FireDAC and have thousands of queries using unnamed params!

Regards
Robert
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: TFDConnection.ExecSQL Bug?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 8, 2014 7:11 AM   in response to: Robert Holler in response to: Robert Holler
Will this become fixed in XE6 Update 2 or are unnamed params deprecated ?

Not fixed, not deprecated. "?" parameter markers never
been supported by AnyDAC / FireDAC. But you can create
a feature request in QC.

Updated: sorry, was wrong. "?" are supported. But there
was bug. It is fixed now. Changes rather will be included
into XE7. I posted patch to attachments:
https://forums.embarcadero.com/thread.jspa?threadID=106861

--
With best regards,
Dmitry Arefiev / FireDAC Architect

Edited by: Dmitry Arefiev on Jul 8, 2014 6:56 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02