?
Solved

Urgent - How to associate Sequence to column.

Posted on 2003-03-31
3
Medium Priority
?
1,838 Views
Last Modified: 2009-04-15
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
Comment
Question by:imrancs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
andrewst earned 150 total points
ID: 8237683
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
 
LVL 10

Author Comment

by:imrancs
ID: 8237844
Thanks it solve my problem. I have checked this its working properly.
0
 
LVL 10

Author Comment

by:imrancs
ID: 8237913
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question