Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1842
  • Last Modified:

Urgent - How to associate Sequence to column.

Hi Experts

I have developed an Oracle Form using Forms 6i. I have a primary key column in the table behind this form. How I can associate/attach a Sequence with the primary key column

Thanx in advance
Regards
Mohammad Imran Malik
0
imrancs
Asked:
imrancs
  • 2
1 Solution
 
andrewstCommented:
There is no "automatic" association of a sequence with a primary key, and there are various ways you can do this:

1) Database trigger:

CREATE OR REPLACE TRIGGER trg BEFORE INSERT ON table1
WHEN NEW.pkcol IS NULL
FOR EACH ROW
BEGIN
  :NEW.pkcol := seq1.NEXTVAL;
END;
/

In this way, the form does not set the pkcol value.  So that the form knows the new value after the insert you would need to set the block's DML Returning Value property to Yes.

2) PRE-INSERT trigger on block:

BEGIN
  SELECT seq1.NEXTVAL
  INTO   :block.pkcol
  FROM   DUAL;
END;

0
 
imrancsAuthor Commented:
Thanks it solve my problem. I have checked this its working properly.
0
 
imrancsAuthor Commented:
I have developed a Form having about 30 fields related to an Item.When i entered the information and save the form, and i am going to eterned new record for next item,in most cases i needed to change only name of the item and remaing information the same as the previouse item, and i don't want to enter all the information again.
When i save a record and change the required fields and save again it updates the existing record not create a new record.
Please tell me how i can achive this.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now