Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Database trigger
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Before - statement-level trigger === Using a BEFORE statement trigger is particularly useful when enforcing database restrictions.<ref>{{Cite web|url=https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/create_trigger.htm|title=Database PL/SQL Language Reference|website=docs.oracle.com}}</ref> This example demonstrate how to enforce a restriction upon someone named "SOMEUSER" on the table phone_book. <syntaxhighlight lang="sql"> CREATE OR REPLACE TRIGGER hauschbc BEFORE INSERT ON SOMEUSER.phone_book BEGIN RAISE_APPLICATION_ERROR ( num => -20050, msg => 'Error message goes here.'); END; </syntaxhighlight> Now, when "SOMEUSER" is logged in after attempting any INSERT this error message will show: SQL Error: ORA-20050: Error message goes here. Custom errors such as this one has a restriction on what the num variable can be defined as. Because of the numerous other pre-defined errors this variable must be in the range of β20000 to β20999.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)