0% found this document useful (0 votes)
1 views4 pages

SQL1

The document details the creation and manipulation of a database table 'emp3' in Oracle SQL, including the insertion of employee records and the creation of views and triggers. It highlights errors encountered during trigger creation and provides successful examples of inserting data and creating triggers for various operations. The document demonstrates the functionality of triggers for handling insertions, updates, and deletions in the database.

Uploaded by

suhel563
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

SQL1

The document details the creation and manipulation of a database table 'emp3' in Oracle SQL, including the insertion of employee records and the creation of views and triggers. It highlights errors encountered during trigger creation and provides successful examples of inserting data and creating triggers for various operations. The document demonstrates the functionality of triggers for handling insertions, updates, and deletions in the database.

Uploaded by

suhel563
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL*Plus: Release 10.2.0.1.

0 - Production on Wed Mar 12 10:22:39 2025

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> create table emp3(emp_id int primary key,name varchar2(50),salary decimal(10,2),created_at


date

);

Table created.

SQL> insert into emp3(emp_id,name,salary,creayed_at)values(1,'navya',30000,sysdate);

insert into emp3(emp_id,name,salary,creayed_at)values(1,'navya',30000,sysdate)

ERROR at line 1:

ORA-00904: "CREAYED_AT": invalid identifier

SQL> insert into emp3(emp_id,name,salary,created_at)values(1,'navya',30000,sysdate);

1 row created.
SQL> insert into emp3(emp_id,name,salary,created_at)values(2,'nethish',25000,sysdate);

1 row created.

SQL> insert into emp3(emp_id,name,salary,created_at)values(3,'deepika',40000,sysdate);

1 row created.

SQL> create view emp_view as

2 select emp_id,name,salary

3 from emp3;

View created.

SQL> create or replace trigger insted_of_trigger

2 instead of insert on emp_view

3 begin

4 insert into emp_id,name,salary)

5 values(:new.emp_id,:new.name,:new.salary);

6 end;

7 /

Warning: Trigger created with compilation errors.

SQL> create or replace trigger before_insert_trigger

2 before insert on emp3

3 for each row


4 begin

5 :new.created_at:=sysdate;

6 end;

7 /

Trigger created.

SQL> set sakashroutput on

SP2-0735: unknown SET option beginning "sakashrout..."

SQL> create or replace trigger after_delete_trigger

2 after delete on emp3

3 for each row

4 begin

5 dbms_output.put_line('emp deleted:'||:old.emp_id);

6 end;

7 /

Trigger created.

SQL> create or replace trigger row_update_trigger

2 before update on emp

3 for each row

4 begin

5 if:new.salary>:old.salary then

6 dbms_output.put_line('salary increased for emp id:'||:new.emp_id);

7 end if;

8 end;
9 /

Warning: Trigger created with compilation errors.

SQL> create or replace trigger statement_update_trigger

2 after update on emp3

3 begin

4 dbms_output.put_line('emp table updated.');

5 end;

6 /

Trigger created.

You might also like