We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Trigger with Sequence and PL/SQL

graziazi
graziazi asked
on
Medium Priority
489 Views
Last Modified: 2012-06-27
Hi. I want to create a BEFORE INSERT trigger for a table 'Manager'. I want the trigger to automatically calculate the manager_id value from a sequence.

I've done the following...
CREATE OR REPLACE TRIGGER manager_trig

BEFORE INSERT ON Manager
FOR EACH ROW
WHEN (NEW.manager_id > 0)


And create the sequence.....

CREATE SEQUENCE manager_seq START WITH 1
INCREMENT BY 1;

I also want to also create a PL block that shows the trigger working,  when INSERT,




Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks morqulo!

I'd also like to create a PL/SQL block where I insert (just using the other colum names)  eg name salary

Author

Commented:
i.e demonstrate the trigger working

Commented:
Type "insert into Manager(...) values(...)" without manager_id column.
If you insert row, then select table and see if manager_id has correct value.

Author

Commented:
Thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.