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
735 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

Industry Leaders: 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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

635 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