?
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
Medium Priority
?
737 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

719 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