Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
Name: Rahul
week 17
*/
--@E:
SET SERVEROUTPUT ON
--creating the trigger
CREATE OR REPLACE TRIGGER trig_dob_ck
BEFORE INSERT OR UPDATE OF date_of_birth ON students
FOR EACH ROW
WHEN (NEW.date_of_birth>SYSDATE)
BEGIN
RAISE_APPLICATION_ERROR(-20000, 'ERROR - THIS STUDENT WAS BORN AFTER TODAY, AMEND STUDENT DATE OF BIRTH!');
END trig_dob_ck;
/
SHOW ERROR --SHOWING THE ERROR IN THE CODE
--Q: What's the result?
--A: Trigger created
--Q: Do you get any errors, if so what are they and how do you solve them?
--A: There were errors as I have missed to use the semi-colon at last before the END statement
--Q: What is the command used to fire your trigger?
--A:
--testing of the created trigger
--testing the inserting data with the invalid data
INSERT INTO students(students_id, students_fullname, student_email, location, date_of_birth)
VALUES(101, 'Chirayu Subedi', '[email protected]', 'Imadol', '22-03-2019')
--testing the inserting data with valid inpiut
INSERT INTO students(students_id, students_fullname, student_email, location)
VALUES(101, 'Chirayu Subedi', '[email protected]', 'Imadol', '22-05-1995')
--UPDATING USING THE INVALID DATA
UPDATE students SET
date_of_birth= '22-05-2019'
WHERE students_id= 101;
--UPDATING USING THE VALID DATA
UPDATE students SET
date_of_birth='15-05-1998'
WHERE students_id= 101;
--Q: What is the result? Is the data inserted into the table? Why?
--A:
CREATE OR REPLACE TRIGGER trig_dob_pk
AFTER INSERT OR UPDATE date_of_birth ON students
FOR EACH ROW
WHEN(NEW.date_of_birth>(today-(365*18)))
BEGIN
IF
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team