--IMPLICIT CURSOR (SQL CURSOR)
SET SERVEROUTPUT ON;
DECLARE
Code ACCOUNTS.EmpNo%Type;
Name ACCOUNTS.EmpName%Type;
TJob ACCOUNTS.Job%Type;
Salary ACCOUNTS.Sal%Type;
BEGIN
DBMS_OUTPUT.ENABLE;
Code := &Employee_Number;
Name := &Name;
TJob := &Job_Title;
Salary := &Salary;
INSERT INTO ACCOUNTS VALUES(Code,Name,Salary,TJob);
Code:=&NewCode;
select * into Code,Name,Salary,TJob from accounts where Empno=Code;
DBMS_OUTPUT.PUT_LINE(Code' 'Name' 'Salary' 'TJob);
END;
/
@ c:\sql6
Enter value for employee_number: 7858
old 8: Code := &Employee_Number;
new 8: Code := 7858;
Enter value for name: 'abhilash'
old 9: Name := &Name;
new 9: Name := 'abhilash';
Enter value for job_title: 'Jocky'
old 10: TJob := &Job_Title;
new 10: TJob := 'Jocky';
Enter value for salary: 786
old 11: Salary := &Salary;
new 11: Salary := 786;
Enter value for newcode: 1021
old 13: Code:=&NewCode;
new 13: Code:=1021;
1021 Meenu K. 9000 Manager
PL/SQL procedure successfully completed.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--EXPLICIT CURSOR
SET SERVEROUTPUT ON;
DECLARE
CURSOR TEmp IS SELECT * FROM ACCOUNTS;
TEmpRec ACCOUNTS%ROWTYPE;
BEGIN
DBMS_OUTPUT.ENABLE;
OPEN TEmp;
LOOP
FETCH TEmp INTO TEmpRec;
EXIT WHEN TEmp%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(TEmpRec.EmpName' with Code 'TEmpRec.Empno' is working as 'TEmpRec.Job' at Rs.'TEmpRec.Sal);
END LOOP;
CLOSE TEmp;
END;
/
@ c:\pra 8
Anoop with Code 2001 is working as Seargent at Rs.40
arun with Code 9899 is working as lawyer at Rs.10
T. N. Raja with Code 8000 is working as Judge at Rs.8000
Meenu K. with Code 1021 is working as Manager at Rs.9000
Sarika M. with Code 1022 is working as Clerk at Rs.6000
Preeti A.. with Code 1023 is working as D. Mgr. at Rs.6600
Manisha P. with Code 1024 is working as Analyst at Rs.9000
Ramesh C. with Code 1025 is working as Peon at Rs.10000
Ramesh C. with Code 1026 is working as Peon at Rs.2000
PL/SQL procedure successfully completed.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Corprova | Saroj Hydraulics | AlphaNumeric | durgeshindia
0 responses:
Post a Comment