Oracle sequence

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
hgyula
Posts: 1
Joined: Wed 29 Aug 2012 10:07

Oracle sequence

Post by hgyula » Wed 29 Aug 2012 10:39

Hi,
I have an application on MSSql, now I'm migrating it to Oracle.
In MsSQL I use identity columns for PrimeryKeys. In Oracle I'm using sequence for PKs, and I have a trigger for each table, which fill the appropriate value for the PK.
In my application I not care directly about fill the PK, becaues the database makes it for me, but when I'm conncted to Oracle, I got the error message "Field ID must have a value"!
(with MSSQL it works fine!)
Can I switch off somehow the TUniTable, or TUniQuery component feater for checking the PK ?
I tried to set then RequiredField = False, but it counts nothing.

Thanks,
gyula

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

Re: Oracle sequence

Post by AlexP » Thu 30 Aug 2012 12:09

hello,


To have a possibility to insert data to the fields with the NOT NULL flag in the database, you should set the UniQuery1.Options.RequiredFields to False, or if you created Persistent fields, then the UniQuery1ID.Required option of the correspondent field should be set to False.

To return the generated value to DataSet exactly after insert, you should change the INSERT query in the UniQuery1.SQLInsert.Text property in the following way:

Code: Select all

INSERT INTO TABLE
  (FIELD_1, .... , FIELD_N)
VALUES
  (:FIELD_1, .... , :FIELD_N)
RETURNING
ID
INTO
:ID
and set the UniQuery1.Options.ReturnParams property to True

Post Reply