Home » Developer & Programmer » Forms » Oracle forms 9i
icon6.gif  Oracle forms 9i [message #226495] Sat, 24 March 2007 03:44 Go to next message
srinivasan83
Messages: 7
Registered: March 2007
Location: coimbatore
Junior Member
hi friends,
i have developed a sequence to generate auto no for emp_id in employee table..it works fine. but i don`t how to implement in oracle forms 9i.. i need sequence generate emp_id before saving the record or insert into table.. i am using forms smart bar menu save button to save the record.. please tell me as soon as possible. waiting for quick reply
thanks in advance
Re: Oracle forms 9i [message #226510 is a reply to message #226495] Sat, 24 March 2007 07:41 Go to previous messageGo to next message
Littlefoot
Messages: 20895
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
One way would be creating a database trigger such as
CREATE OR REPLACE TRIGGER trg_emp_id
  BEFORE INSERT ON DEPT
  FOR EACH ROW
BEGIN
  IF :NEW.emp_id IS NULL THEN
     SELECT my_seq.NEXTVAL INTO :NEW.emp_id FROM dual;
  END IF;
END;
/


If you, on the other hand, decide to keep code in a form, you might put
IF :emp_id IS NULL THEN
   SELECT my_seq.NEXTVAL INTO :emp_id FROM dual;
END IF;
into a PRE-COMMIT trigger.
Re: Oracle forms 9i [message #226924 is a reply to message #226510] Mon, 26 March 2007 23:37 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
If you are writing a form to handle a master/detail relationship you can put the 'nextval' into the When-Create-Record for the various blocks.

David
Previous Topic: custom logon screen(new_form)
Next Topic: exit_form question
Goto Forum:
  


Current Time: Mon Dec 05 21:12:04 CST 2016

Total time taken to generate the page: 0.07910 seconds