6 - 10 Edited Programs-4
6 - 10 Edited Programs-4
6. Develop a program using CURSOR, FOR UPDATE CURSOR, WHERE CURRENT of clause and
CURSOR variables.
AIM:
To develop a program using cursor ,for update cursor where current of clause and cursor variables.
ALGORITHM:
STEP 2: create a table and use the following attributes such as eid, ename, depid, deptname, age,
gender and salary.
PROGRAM:
SQL> declare
2 cursor salaryupdate is
3 select eid,ename,deptid,deptname,age,salary from employ
4 where deptid=33
5 for update of salary nowait;
6 sal salaryupdate%rowtype;
7 begin
8 open salaryupdate;
9 loop
10 fetch salaryupdate into sal;
11 exit when salaryupdate%notfound;
12 if sal.deptid=1 then
13 update employ
14 set salary=sal.salary+100
15 where current of salaryupdate;
16 end if;
17 end loop;
18 commit;
19 close salaryupdate;
20 end;
21 /
PL/SQL procedure successfully completed.
AIM:
ALGORITHM:
STEP 5: Use the trigger delete row query to delete but the trigger not deleted.
PROGRAM:
SQL> /
Enter value for routeid: 13
Enter value for busname: srpk
Enter value for originate: sakthi
Enter value for terminate: erode
Enter value for distance: 50
Enter value for fare: 45.00
Enter value for bookingday: friday
old 1: insert into route values('&routeid','&busname','&originate','&terminate','&distance','&fare
new 1: insert into route values('13','srpk','sakthi','erode','50','45.00','friday')
1 row created.
SQL>/
Enter value for routeid:12
Enter value for busname:pkp
Enter value for originate:salem
Enter value for terminate:erode
Enter value for distance:65
Enter value for fare:60.00
Enter value for bookingday:Thursday
Old 1:insert into route values(‘&routeid’,’&busname’,’&originate’,’&terminate’,’&distance’,;&fare
New 1: insert into route vaues(‘12’,’pkp’,’salem’,’erode’,’65’,’60.00’,’thursday’)
1 row created.
RESULT:Thus the above program has been executed and verified successful.
Algorithm:.
Step1: Start the process.
Step2: Create table and use following attributes such as empid,empname, department,
designation,salary etc.
Step3: Insert values for above attributes.
Step4: Create a save point for each row using the query save point object name.
Step5: Use rollback query to delete last row.
Step6: Use grent and revoke query.
Step7: Display the table using select query.
Step8: Stop the process .
PROGRAM:
SQL> create table emp(empid number(4),empname varchar(20),dept varchar(20),designation
varchar(20),dateofjoining date,daysworked number(2),basicpay decimal(10,2),da decimal(10,2),hra
decimal(10,2),medicalallo decimal(10,2),grosspay decimal(10,2),pf decimal(10,2),tax
decimal(10,2),totaldeduction decimal(10,2),netpay decimal(10,2));
Table created.
RESULT:Thus the above program has been executed and verified successful.
__________________________________________________________________________________
1 row created.
SQL> /
Enter value for regno: 12
Enter value for name: dharani
Enter value for dob: 15 jan 2005
Enter value for programme: b.com
Enter value for branch: commerce
Enter value for sem: II
Enter value for java: 80
Enter value for dbms: 80
Enter value for mp: 80
Enter value for total: 240
Enter value for percentage: 80
old 1: insert into marksheet values('®no','&name','&dob','&programme','&branch','&sem','&java',
new 1: insert into marksheet values('12','dharani','15 jan 2005','b.com','commerce','II','80','80'
1 row created.
SQL> /
Enter value for regno: 13
Enter value for name: poorani
Enter value for dob: 8 feb 2000
Enter value for programme: b.sc
Enter value for branch: ct
Enter value for sem: iii
Enter value for java: 80
Enter value for dbms: 85
Enter value for mp: 85
Enter value for total: 250
Enter value for percentage: 83
old 1: insert into marksheet values('®no','&name','&dob','&programme','&branch','&sem','&
new 1: insert into marksheet values('13','poorani','8 feb 2000','b.sc','ct','iii','80','85',
1 row created.
RESULT:Thus the above program has been executed and verified successful.
Algorithm:.
Step 1: Start the process.
Step 2: Create table and use the following attributes such as empno,empname, salary.
Step 3: Insert values for above attributes.
Step 4: Create on object for the attributes id and salary as v- empid and v -sal.
Step5: Stop the process.
PROGRAM:
SQL> create table emp(empno number(3),empname varchar(20),salary decimal(10,5))
Table created.
1 row created.
SQL> /
Enter value for empno: 102
Enter value for empname: sindhu
Enter value for salary: 20000
old 1: insert into emp values('&empno','&empname','&salary')
new 1: insert into emp values('102','sindhu','20000')
1 row created.
SQL> /
Enter value for empno: 103
Enter value for empname: dharani
Enter value for salary: 20000
old 1: insert into emp values('&empno','&empname','&salary')
new 1: insert into emp values('103','dharani','20000')
1 row created.
SQL> /
Enter value for p_raise: 0.20
old 4: v_raise number(3,2):=&p_raise;
new 4: v_raise number(3,2):=0.20;
Enter value for p_empid: 111
old 7: where empno=&p_empid for UPDATE NOWAIT;
new 7: where empno=111 for UPDATE NOWAIT;
NO SUCH EMPLOYEE IN TABLE