Solved

Oracle package global variable seen by procedures, error "PLS-00225: subprogram or cursor reference is out of scope"

Posted on 2013-07-01
2
732 Views
Last Modified: 2013-07-01
I'm trying to use a global variable within a package for all procedures to see that global variable.  I tried procedure A.variable_name  for global variable.  

Here is how I'm trying to use a global variable to pass variables within a package from one procedure A to procedure B but i get an error "PLS-00225: subprogram or cursor reference is out of scope"


CREATE OR REPLACE PACKAGE PKG_1
AS
   PROCEDURE A;

   PROCEDURE B;

END PKG_1;
/

CREATE OR REPLACE PACKAGE BODY PKG_1
AS
 PROCEDURE A
 IS
   
   CURSOR cur_A
   IS
 SELECT DISTINCT data
  FROM table_X;
   

 BEGIN
   
   OPEN cur_A;

   <<fetch_cur_A>>
   LOOP
      FETCH cur_A
       INTO rec_A;

      EXIT fetch_A WHEN cur_A%NOTFOUND;

        SELECT data
        INTO variable_name_A
        FROM table_A
        WHERE column_A = rec_A;

        IF variable_name_A is NOT NULL THEN

          B;  -- call procedure B

        END IF;

    END LOOP;

   CLOSE cur_A;

   END A;
 
  PROCEDURE B
   
   BEGIN
         
             SELECT x, y, z
               INTO v_x, v_y, v_z
             from table_Z
            WHERE column_P = (A.variable_name_A);  --using global variable by using                 --procedure_name.variable_name
                 
  END B;

END PKG_1;
0
Comment
Question by:talahi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 39290848
You cannot use procedure A's variables outside procedure A.

Declare a global package variable.  Then use it.


CREATE OR REPLACE PACKAGE PKG_1
AS
   My_Global_variable    varchar2(100);

   PROCEDURE A;

   PROCEDURE B;

END PKG_1;
/

Open in new window

0
 

Author Closing Comment

by:talahi
ID: 39290872
Thanks, saves me time from trying to make that work.  I'll try to OUT the variable from a and IN to B.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question