Home » SQL & PL/SQL » SQL & PL/SQL » How can I separate cursor spec. from body?
How can I separate cursor spec. from body? [message #37657] Tue, 19 February 2002 06:37 Go to next message
marco
Messages: 46
Registered: March 2001
Member
hi,

I'd like to separate a cursor specification from its body but I get PLS-00488, at compilation time, where I reference the cursor variable with P1.C1 in P2. How should one code this?
Thanks,

Marco

----------------------------------------------
CREATE OR REPLACE PACKAGE P1 AS

CURSOR c1 RETURN students%ROWTYPE;
END P1;
/

CREATE OR REPLACE PACKAGE BODY P1 AS

CURSOR c1 RETURN students%ROWTYPE IS
select * FROM students WHERE Major = 'Music';

END P1;
/

---------------------------------------------
CREATE OR REPLACE PROCEDURE P2 IS

c_curstud P1.C1; <------ PLS-00488 Compile error

BEGIN

FOR v_cs IN c_curstud LOOP
...
END LOOP;
CLOSE c_curstud;

END P2;
/
Re: How can I separate cursor spec. from body? [message #37659 is a reply to message #37657] Tue, 19 February 2002 06:56 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
here is an example, which uses scott.emp table

CREATE OR REPLACE PACKAGE P1 AS
CURSOR c1 RETURN emp%ROWTYPE IS
select * FROM emp;--
END P1;
/

CREATE OR REPLACE PROCEDURE P2 IS
BEGIN
FOR v_cs IN p1.c1 LOOP
dbms_output.put_line('1111');
END LOOP;
END P2;
/
Previous Topic: Different environments
Next Topic: Dynamic SQLs
Goto Forum:
  


Current Time: Thu Apr 25 08:07:15 CDT 2024