Beruflich Dokumente
Kultur Dokumente
1.)
PL/SQL Cursors
Create a table Student (regno, name, dept, cgpa) with minimum five
records
1. Create an Explicit Cursor to list all the Student
having cgpa >9.0 and transfer it to a new table.
NAME
--------------------
andiappan
2.)
Write an Implicit Cursor to display the details of
CSE student.
SQL> declare
2 a_name Student_info.name%type;
3 a_regno Student_info.regno%type;
4 a_dept Student_info.dept%type;
5 a_cgpa Student_info.cgpa%type;
6 cursor try_2 is
7 select name,regno,dept,cgpa from Student_info where dept='cse';
8 begin
9 open try_2;
10 fetch try_2 into a_name,a_regno,a_dept,a_cgpa;
11 insert into name_2 values(a_name,a_regno,a_dept,a_cgpa);
12 dbms_output.put_line(a_name||''||a_regno||''||a_dept||''||a_cgpa);
13 close try_2;
14 end;
15 /
vasanth1006cse9.2
PL/SQL Triggers
1. Considering the above relation, raise a trigger,
when the cgpa exceeds 9.0 or goes below 4.0.
SQL> create trigger cg
2 before insert on student
3 for each row
4 when(NEW.cgpa>9.0 or NEW.cgpa<4.0)
5 begin
6 if(NEW.cgpa>9.0)
7 dbms_output.putline('cgpa below 9.0');
8 then
9 dbms_output.putline('cgpa below 4.0');
10 end if;
11 end;
12 /
SQL>Trigger created
1 row created.
Trigger created
1 row created.