Page 1 of 1

Primary Key as Sequence in oracle

Posted: Mon 11 Jan 2010 10:09
by flyy
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.

Posted: Mon 11 Jan 2010 10:46
by flyy
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.

Posted: Mon 11 Jan 2010 11:31
by Challenger
You should set the KeyFields property of TUniQuery to FIELD1.

Posted: Mon 11 Jan 2010 11:45
by flyy
thanks for the answer, how could i missed this.