Results 1 to 2 of 2

Thread: global variable

  1. #1
    Join Date
    Nov 2003
    Posts
    33

    Unanswered: global variable

    I have created one global varible in pl/sql package which i am using to store the value of approvers.
    I have 10 diffrent procedure for 10 different approvers in one package and i wanted that global variable to store the value of previous approver when it executing the next one. but it is not happening.
    I declare goble varible in package body
    CREATE OR REPLACE PACKAGE BODY B AS
    g_list_of_apporvers varchar2(1500) :=NULL;

    PROCEDURE1
    name_of_approver varchar2(100);
    other statments;
    g_list_of_apporvers := g_list_of_apporvers || name_of_approver
    END;
    PROCEDURE2
    name_of_approver varchar2(100);
    other statments;
    g_list_of_apporvers := g_list_of_apporvers || name_of_approver;
    END;
    ....
    ....
    .....
    .....
    PROCEDURE10
    name_of_approver varchar2(100);
    other statments;
    g_list_of_apporvers := g_list_of_apporvers || name_of_approver;
    END;

    DBMS_OUT.PUT_LINE(G_LIST_OF_APPROVERS);
    END OF PACKAGE BODY

    I am not able to get value of all the 10 approvers.


    thanks in advance

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    OK, you're not able to get this value. But, what DO you get? Anything or nothing? Error message? You should, as DBMS_OUTPUT.PUT_LINE (btw, you have DBMS_OUT) can't be outside of a procedure (that is, can't be used as a standalone statement in a package body). Try to compare this example with yours and correct what's wrong (procedure 3 writes your global variable's value to the screen):
    Code:
    SQL> CREATE OR REPLACE PACKAGE approvers IS
      2  PROCEDURE proc1;
      3  PROCEDURE proc2;
      4  PROCEDURE proc3;
      5  END;
      6  /
    
    Package created.
    
    SQL> CREATE OR REPLACE PACKAGE BODY approvers IS
      2  g_ap_name VARCHAR2(1500) := NULL;
      3
      4  PROCEDURE proc1 IS
      5  BEGIN
      6  g_ap_name := g_ap_name || ' proc1 ';
      7  END;
      8
      9  PROCEDURE proc2 IS
     10  BEGIN
     11  g_ap_name := g_ap_name || ' proc2 ';
     12  END;
     13
     14  PROCEDURE proc3 IS
     15  BEGIN
     16  g_ap_name := g_ap_name || ' proc3 ';
     17
     18  dbms_output.put_line(g_ap_name);
     19  END;
     20
     21  END approvers;
     22  /
    
    Package body created.
    
    SQL> set serveroutput on;
    SQL> EXECUTE approvers.proc1;
    
    PL/SQL procedure successfully completed.
    
    SQL> EXECUTE approvers.proc2;
    
    PL/SQL procedure successfully completed.
    
    SQL> EXECUTE approvers.proc3;
    proc1  proc2  proc3
    
    PL/SQL procedure successfully completed.
    
    SQL>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •