Primary Key as Sequence in oracle

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
flyy
Posts: 17
Joined: Fri 18 Sep 2009 08:34

Primary Key as Sequence in oracle

Post by flyy » Mon 11 Jan 2010 10:09

hi,

I have a table which has a primary key that get its value from a sequence in Oracle Database. Is there a way to say this to uniquery getting this sequence value? I searched for forum but I couldnt find any answer. for ex:

Code: Select all

Create Table Dummy 
(
  Field1 Number Primary Key,
  Field2 Varchar2(10)
);
I am using uniquery and my sql is 'Select * From Dummy'. I am generating the sql statements. Now how can I say to the uniquery to use a sequence for Field1 and also this field is primary key.

As I see, in options menu of uniquery, there are some options called, "Key Sequence" and "Sequence Mode" but there is no field info which will has the seq value.

ps: I also have to set roAfterInsert to true in refresh options. because of there is no value of primary key value, I got refresh failed X record found...
thanks.

flyy
Posts: 17
Joined: Fri 18 Sep 2009 08:34

Post by flyy » Mon 11 Jan 2010 10:46

I should add, I am setting "Key Sequence" as my sequence and "Sequence Mode" as smInsert and uncheck "Requered" property of field "Field1" (if I dont unchecked it, I got this field must not be null error) and after that I try to insert and post a row but I got primary key can not be null error from database, as if UniQueryis not using sequence that my assign to "key sequence".

and I also change SQLInsert statment and write to there my sequence as

Code: Select all

INSERT INTO DUMMY
  (FIELD1, FIELD2)
VALUES
  (a_Seq.NextVal, :FIELD2)
returning Field1 into :field1
it works.

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Mon 11 Jan 2010 11:31

You should set the KeyFields property of TUniQuery to FIELD1.

flyy
Posts: 17
Joined: Fri 18 Sep 2009 08:34

Post by flyy » Mon 11 Jan 2010 11:45

thanks for the answer, how could i missed this.

Post Reply