|
|
|
|
| Re: facing problem in this pl-sql code using cursor [message #565727 is a reply to message #565720] |
Thu, 06 September 2012 07:31   |
 |
Michel Cadot
Messages: 68775 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Welcome to the forum.
Please always copy and paste your SQL*Plus session like:
SQL> declare
2 cursor cpf is
3 select empno, ename, sal basic, sal*0.45 hra, sal*0.35 da, sal*0.15 pf, deptno
4 from emp
5 where sal>4000;
6 i cpf%rowtype;
7 vgross number;
8 begin
9 open cpf;
10 loop
11 fetch cpf into i;
12 if cpf%found then
13 vgross:=i.basic+i.hra+i.da-i.pf;
14 DBMS_OUTPUT.PUT_LINE(i.empno||' '||i.ename||' '||i.basic||' '||i.hra||' '||
15 i.da||' '||i.pf||' '||i.deptno||' '||i.vgross);
16 else
17 exit;
18 end if;
19 end loop;
20 close cpf;
21
22 /
declare
*
ERROR at line 1:
ORA-06550: line 21, column 0:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe
You miss "end;" at line 21 to end the PL/SQL block.
Please Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.
Regards
Michel
|
|
|
|
| Re: facing problem in this pl-sql code using cursor [message #565731 is a reply to message #565727] |
Thu, 06 September 2012 07:43   |
 |
Michel Cadot
Messages: 68775 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
When you'll done with this error you will face another one:
SQL> declare
2 cursor cpf is
3 select empno, ename, sal basic, sal*0.45 hra, sal*0.35 da, sal*0.15 pf, deptno
4 from emp
5 where sal>4000;
6 i cpf%rowtype;
7 vgross number;
8 begin
9 open cpf;
10 loop
11 fetch cpf into i;
12 if cpf%found then
13 vgross:=i.basic+i.hra+i.da-i.pf;
14 DBMS_OUTPUT.PUT_LINE(i.empno||' '||i.ename||' '||i.basic||' '||i.hra||' '||
15 i.da||' '||i.pf||' '||i.deptno||' '||i.vgross);
16 else
17 exit;
18 end if;
19 end loop;
20 close cpf;
21 end;
22 /
i.da||' '||i.pf||' '||i.deptno||' '||i.vgross);
*
ERROR at line 15:
ORA-06550: line 15, column 44:
PLS-00302: component 'VGROSS' must be declared
ORA-06550: line 14, column 4:
PL/SQL: Statement ignored
Your cursor has no "vgross" field.
Regards
Michel
|
|
|
|
|
|
|
|
|
|
|
|