Can't insert records using ODAC version 7.20 and Delphi 2010

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
franklinfreitas
Posts: 2
Joined: Tue 28 Jun 2011 20:47

Can't insert records using ODAC version 7.20 and Delphi 2010

Post by franklinfreitas » Tue 28 Jun 2011 20:52

I’m migrating our applications from Delphi 5 using ODAC (Ver. 5.50.0.16) to Delphi 2010 using ODAC (Ver. 7.20.0.6). In our applications we commonly use the TOraTable components. Inside each object’s properties we specify the properties KeyFields and KeySequence. In the Delphi 5 version (using ODAC 5.50) new records are inserted without a problem. The component automatically makes the query "SELECT SEQNAME.NEXTVAL FROM DUAL” and assigns the returned value to the table and field where we want to insert records, but this doesn’t work when using Delphi 2010 with ODAC 7.20, instead a value of 0 is stored in the table for the inserted record.

Is this a bug in the component TQraTable for the ODAC version 7.20.0.6 or is there another property or approach that I should consider ?

Notes:
1.- We only get errors when inserting records, retrieving data and updates work fine.
2.- We are aware the we could write a function to query the NextVal manually, but it would require a lot of effort to fix this in all the applications, so we would like to know if there’s a way to do it since the previous version worked without any issues.

Thanks for your help

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 29 Jun 2011 08:56

Hello,

I cannot reproduce the problem.
If you've set the KeyFields and KeySequence properties correctly, OraTable will generate the Insert query correctly.

The Insert query in the latest ODAC versions looks like

Code: Select all

INSERT INTO T_TABLE
  (ID, TEXT)
VALUES
  (sq_t_table.NEXTVAL, :TEXT)
RETURNING
  ID
INTO
  :ID
Please turn on the debug mode:

Code: Select all

uses ..., odacvcl;
.....
OraTable.Debug := true;
and check that the query is generated and executed correctly using a third-party application, for example, SQL Plus.

franklinfreitas
Posts: 2
Joined: Tue 28 Jun 2011 20:47

Post by franklinfreitas » Thu 07 Jul 2011 17:20

We already try checking the properties for the component and everything looks ok. In fact with our previous version project (Delphi 5) it works fine.

All we did was to open the Delphi 5 project using Delphi 2010. We were expecting it to work without any issues.

We will try installing the Delphi 2010 and the ODAC from scratch in another machine and see what happens.

I'll keep you posted

Thanks for your help

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 08 Jul 2011 10:41

Hello,

Please try reproducing this situation on a clean project, created with Delphi 10. If this problem persists, please send this project and the script, creating the table and the sequence, to alexp*devart*com.

Post Reply