In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "database trigger example analysis", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "database trigger example analysis" bar!
We maintain a customer table whose contents are not allowed to be modified on Saturdays and Sundays. This is the customer list:
CREATE TABLE plch_customers (custnum INTEGER, custname VARCHAR2)
I need to create a trigger to prevent any insertions, modifications, and deletions to this table over the weekend. I wrote this code:
CREATE OR REPLACE TRIGGER plch_customers_maint_trg / * TEXT*/DECLAREBEGIN IF TO_CHAR (SYSDATE, 'DY',' NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT',' SUN') THEN RAISE_APPLICATION_ERROR (- 20000, 'Customers maintained Monday-Friday only.'); END IF;END;/
What options can be used to replace the / * TEXT*/, in the article so that this trigger does not allow any DML operations to be performed on the plch_ customers table over the weekend, and each statement is triggered only once?
(A)
BEFORE UPDATE ON plch_customers FOR EACH ROWBEFORE INSERT ON plch_customers FOR EACH ROWBEFORE DELETE ON plch_customers FOR EACH ROWSQL > CREATE OR REPLACE TRIGGER plch_customers_maint_trgBEFORE UPDATE ON plch_customers FOR EACH ROWBEFORE INSERT ON plch_customers FOR EACH ROWBEFORE DELETE ON plch_customers FOR EACH ROWDECLAREBEGIN IF TO_CHAR (SYSDATE, 'DY',' NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT',' SUN') THEN RAISE_APPLICATION_ERROR (- 20000, 'Customers maintained Monday-Friday only.'); END IF END;ORA-04079: invalid trigger description SQL >
(B)
BEFORE UPDATE ON plch_customersBEFORE INSERT ON plch_customersBEFORE DELETE ON plch_customersSQL > CREATE OR REPLACE TRIGGER plch_customers_maint_trgBEFORE UPDATE ON plch_customersBEFORE INSERT ON plch_customersBEFORE DELETE ON plch_customersDECLAREBEGIN IF TO_CHAR (SYSDATE, 'DY',' NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT',' SUN') THEN RAISE_APPLICATION_ERROR (- 20000, 'Customers maintained Monday-Friday only.'); END IF;END;ORA-04079: invalid trigger description SQL >
(C)
BEFORE UPDATE, INSERT OR DELETE ON plch_customersSQL > CREATE OR REPLACE TRIGGER plch_customers_maint_trgBEFORE UPDATE, INSERT OR DELETE ON plch_customersDECLAREBEGIN IF TO_CHAR (SYSDATE, 'DY',' NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT',' SUN') THEN RAISE_APPLICATION_ERROR (- 20000, 'Customers maintained Monday-Friday only.'); END IF;END;ORA-00969: missing ON keyword SQL >
(D)
BEFORE UPDATE OR INSERT OR DELETE ON plch_customers FOR EACH ROWSQL > Trigger createdSQL >
(E)
BEFORE UPDATE OR INSERT OR DELETE ON plch_customersSQL > Trigger createdSQL >
Answer E
D is not the answer because each line is triggered and does not meet the condition.
Thank you for your reading, the above is the content of "Database trigger example Analysis". After the study of this article, I believe you have a deeper understanding of the database trigger example analysis of this problem. the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.