RE: trigger sequence conepts

RE: trigger sequence conepts

 

  

Luis,

Try this construct:

CREATE OR REPLACE TRIGGER TRIGGER_NAME_HERE
BEFORE INSERT ON OWNER.TABLENAME
FOR EACH ROW
BEGIN
SELECT OWNER.SEQUENCE_NAME.nextval into :new.PRIMARY_KEY_FIELD from dual;
END;
/


HTH
John.

-----Original Message-----
From: luis [mailto:oracledba-ezmlmshield-x98705181.[Email address protected]
Sent: 31 May 2006 19:35
To: LazyDBA Discussion
Subject: trigger sequence conepts

G's

I have built the trigger utilising the sequence, in theory I want the
trigger to use the sequence to update the primary key, this in theory to be
done before insert or update. Now when inserting I get an ORA-02291
integrity constrainty about the primary key.

I thought the trigger would use the sequence and insert into the primary
key and then the insert would take effect.

I am aware my understanding of it may be impaired.

Please let me know.

Luis


This communication is intended for the addressee(s) only.
Please notify the sender if received in error. Internet email
is not to be treated as a secure means of communication.
Cheshire Constabulary monitors all Internet and email activity
and requires it is used for official communications only. Thank
you for your co-operation.


--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: see http://www.lazydba.com
By using this list you agree to these
terms:http://www.lazydba.com/legal.html

-----------------------------------------
Information in this email including any attachments may be
privileged, confidential and is intended exclusively for the
addressee. The views expressed may not be official policy, but the
personal views of the originator. If you have received it in error,
please notify the sender by return e-mail and delete it from your
system. You should not reproduce, distribute, store, retransmit,
use or disclose its contents to anyone.

Please note we reserve the right to monitor all e-mail
communication through our internal and external networks.

SKY and the SKY marks are trade marks of British Sky Broadcasting
Group plc and are used under licence. British Sky Broadcasting
Limited (Registration No. 2906991), Sky Interactive Limited
(Registration No. 3554332), Sky-In-Home Service Limited
(Registration No. 2067075) and Sky Subscribers Services Limited
(Registration No. 2340150) are direct or indirect subsidiaries of
British Sky Broadcasting Group plc (Registration No. 2247735). All
of the companies mentioned in this paragraph are incorporated in
England and Wales and share the same registered office at Grant
Way, Isleworth, Middlesex TW7 5QD.


Oracle LazyDBA home page