error rises as INVALID CURSOR [message #588852] |
Fri, 28 June 2013 22:52  |
 |
gowthamsanj
Messages: 18 Registered: June 2013 Location: tirupur
|
Junior Member |
|
|
HI
I AM NEW TO PL SQL, WHILE DEVELOPING PLSQL I FACE CERTAIN ERROR, I HOPE SOME OF EXPERTS WILL HELP ME
THANK YOU
CODING
CREATE OR replace PROCEDURE Ph
IS
CURSOR c_ph IS
SELECT *
FROM emp;
emp_rec emp%ROWTYPE;
mb VARCHAR(40);
eid NUMBER;
BEGIN
OPEN c_ph;
LOOP
FETCH c_ph INTO emp_rec;
eid := emp_rec.employee_id;
mb := '+91 '
||Substr(emp_rec.phone_number, 1, 3)
||'-'
||Substr(emp_rec.phone_number, 5, 3)
||'-'
||Substr(emp_rec.phone_number, 9, 3);
UPDATE emp
SET ph_new = mb
WHERE employee_id = eid;
COMMIT;
exit WHEN c_ph%NOTFOUND;
CLOSE c_ph;
END LOOP;
END;
/
ERROR RAISED
declare
*
ERROR at line 1:
ORA-01001: invalid cursor
ORA-06512: at line 11
[EDITED by LF: formatted code & applied [code] tags]
[Updated on: Sat, 29 June 2013 03:06] by Moderator Report message to a moderator
|
|
|
|
Re: error rises as INVALID CURSOR [message #588854 is a reply to message #588853] |
Fri, 28 June 2013 23:04   |
 |
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
Please explain what you see below
[oracle@localhost ~]$ sqlplus hr/hr
SQL*Plus: Release 11.2.0.2.0 Production on Fri Jun 28 21:01:49 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create or replace view emp as select * from employees;
View created.
SQL> set term on echo on
SQL> create or replace procedure ph
is
cursor c_ph is select * from emp;
emp_rec emp%rowtype;
mb varchar(40);
eid number;
begin
open c_ph;
loop
fetch c_ph into emp_rec;
eid:=emp_rec.employee_id;
mb:='+91 '||substr(emp_rec.phone_number,1,3)||'-'||substr(emp_rec.phone_number,5,3)||'-'||substr(emp_rec.phone_number,9,3);
update emp set ph_new=mb where employee_id=eid;
commit;
exit when c_ph%notfound;
close c_ph;
end loop;
end;
/ 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE PH:
LINE/COL ERROR
-------- -----------------------------------------------------------------
13/1 PL/SQL: SQL Statement ignored
13/16 PL/SQL: ORA-00904: "PH_NEW": invalid identifier
SQL>
Please read and follow the forum guidelines, to enable us to help you:
http://www.orafaq.com/forum/t/88153/0/
|
|
|
|
|
Re: error rises as INVALID CURSOR [message #588860 is a reply to message #588855] |
Sat, 29 June 2013 00:30   |
 |
Michel Cadot
Messages: 68765 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
gowthamsanj wrote on Sat, 29 June 2013 06:08sorry to inform this before : ph_new is a new column created in emp table as varchar2(40)
So post the CREATE TABLE statement for your table so we can reproduce what you have.
Use SQL*Plus and copy and paste your session, the WHOLE session.
Before, 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" or "Preview Quick Reply" button to verify.
Also always post your Oracle version, with 4 decimals.
And do NOT post in UPPER case.
Regards
Michel
[Updated on: Sat, 29 June 2013 00:31] Report message to a moderator
|
|
|
|
|
|