Can we call a package inside a package

Dear Sir
Can we create a package inside a package or can we call a a package inside a package?.If yes.How we can create and call a package inside a package?
Regards
Thakur Manoj

[email protected] wrote:
Dear Sir
Can we create a package inside a package NO, you cant do that.
or can we call a a package inside a package?.YES, you can do that. Just call it. <package_name>.<procedure_or_function_name>

Similar Messages

  • Can I call a function in another package?

    Dear all,
    Can I call a function in another package?
    Say I have package A, and package B.
    Is it possible for me to call a function in inside package A, within a function inside package B?
    If yes, what's the syntax.
    Thanks in advance!

    The variable in the calling package that will receive the value of the function in the other package needs to be defined based on that type in the other package directly:
    sql>create or replace package pkg_a
      2  is
      3    type testTable is table of varchar2(10) index by binary_integer;
      4 
      5    function f_a return testTable;
      6  end;
      7  /
    Package created.
    sql>create or replace package body pkg_a
      2  is
      3    function f_a
      4      return testTable
      5    is
      6      v_table testTable;
      7    begin
      8      v_table(1) := 'One';
      9      v_table(2) := 'Two';
    10      return v_table;
    11    end; 
    12  end;
    13  /
    Package body created.
    sql>create or replace package pkg_b
      2  is
      3    procedure p_b;
      4  end; 
      5  /
    Package created.
    sql>create or replace package body pkg_b
      2  is
      3    procedure p_b
      4    is
      5      v_table pkg_a.testTable;  -- this variable has to be based on the type in pkg_a
      6    begin
      7      v_table := pkg_a.f_a;
      8      for i in 1..v_table.count loop
      9        dbms_output.put_line( v_table(i) );
    10      end loop;
    11    end;
    12  end; 
    13  /
    Package body created.
    sql>exec pkg_b.p_b
    One
    Two
    PL/SQL procedure successfully completed.

  • Call a function inside a package from a stored procedure

    Hello:
    I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
    I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
    can I do the following in proc_c:
    my_cursor1 SYS_REFCURSOR;
    begin
    my_cursor1 := exec pack_a.func_b
    end
    It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.

    guys:
    Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
    I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
    DECLARE TEMP VARCHAR2(100);
    BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
    I tried to use 'set serveroutput on' and got the following error:
    ERROR:
    ORA-06502: PL/SQL: numeric or value error: host bind array too small
    ORA-06512: at line 1
    I am kind of confused now. thank you for your help.
    Jack
    Here is my procedure:
    create or replace
    PROCEDURE PROC_SEARCH
    ( AGENCY_ID IN VARCHAR2,
    DEVICE_ID IN VARCHAR2,
    L_NAME IN VARCHAR2,
    F_NAME IN VARCHAR2,
    SEX IN VARCHAR2,
    DOB IN VARCHAR2,
    CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
    AS
    v_agy_id varchar2(10);
    v_device_id varchar2(20);
    v_l_name varchar2(25);
    v_f_name varchar2(15);
    v_sex varchar2(1);
    v_dob date;
    -- this cursor is going to be used to store a list of warrant matching
    -- name search criteria
    cad_srch_cursor sys_refcursor;
    objSrch SEARCH_RESULT_TEMP%ROWTYPE;
    BEGIN
    cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
    LOOP
    FETCH cad_srch_cursor INTO objSrch;
    EXIT WHEN cad_srch_cursor%NOTFOUND;
    --insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
    CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
    dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
    end LOOP;
    END PROC_LAWS_SEARCH;
    -----------------------------------------

  • Display invalid pattern name while calling the procedure inside the package

    Hi ,
    I'am trying to call a package which is having procedure ,from JDBC in which one of the return type is Varray from the procedure.When i'am calling the procedure inside the package
    from java showing invalid name pattern name.Just i'am placing the code snippet for package and calling java through package.
    Package body
    create or replace package body Rewards_Summary_Package as
    PROCEDURE Rewards_Summary_Procedure
    (v_Tot_Earned_Points OUT NUMBER, v_TOT_REDEEMED OUT NUMBER, v_TOT_PTS_EXP OUT NUMBER,
    v_TOT_AVAILABLE OUT NUMBER, v_TIER_NAME OUT VARCHAR2,VA OUT t_varray,V_PR_CON_ID IN VARCHAR2) AS
    v_ACCRUALED_VAL NUMBER := 0;
    v_USED_VAL NUMBER := 0;
    /*v_TOT_ACCRUALED_VAL NUMBER := 0;
    v_TOT_USED_VAL NUMBER := 0;
    V_PR_TIER_ID VARCHAR2(30);
    V_PR_CON_ID VARCHAR2(30);
    V_EXPIRY_DT DATE;
    v_month varchar2(30);
    v_date date;
    v_next_month_date date;
    v_TIER_NAME VARCHAR2(50);
    v_TOT_AVAILABLE NUMBER := 0;
    v_EARNED NUMBER := 0;
    v_TOT_EARNED NUMBER := 0;
    v_TOT_REDEEMED NUMBER := 0;
    v_TOT_EXPIRED NUMBER := 0;
    v_EARNED_TOTAL NUMBER := 0;
    v_TOT_EXPIRED_MONTH NUMBER := 0;
    v_TOT_PTS_EXP NUMBER := 0;
    v_TOT_RDMD_CANCELLED NUMBER :=0;
    v_TOT_EARNED_POINTS NUMBER :=0;*/
    v_FIRST_DT DATE;
    v_LAST_DT DATE;
    v_MEMBER_ID VARCHAR2(30);
    V_EXPIRED_VAL Number;
    v_TOT_PRDPTS_RDMD NUMBER := 0;
    v_TOT_PTS_RDMD NUMBER := 0;
    v_CAN_ACCRUAL_POINTS NUMBER := 0;
    BEGIN
    /*TotalRwdPoints and Tier Name*/
    SELECT TR.NAME,MEM.POINT_TYPE_A_VAL,MEM.ROW_ID INTO v_TIER_NAME,v_TOT_AVAILABLE,v_MEMBER_ID
    FROM SIEBEL.S_LOY_MEMBER MEM, SIEBEL.S_LOY_TIER TR WHERE MEM.PR_DOM_TIER_ID=TR.ROW_ID
    AND MEM.PR_CON_ID=V_PR_CON_ID;
    vTotPrdPtsRdmd
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PRDPTS_RDMD from SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Product'
    AND A.TXN_ID IS NOT NULL;
    vTotPtsRdmd
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PTS_RDMD from SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND (A.TYPE_CD='Product' or A.TYPE_CD='Transfer')
    AND A.TXN_ID IS NOT NULL;
    vTotRewardPtExp
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PTS_EXP FROM SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Expired'
    AND a.TXN_ID IS NULL;
    vCanAccrualPoints
    SELECT NVL(SUM(A.ACCRUALED_VALUE),0) INTO v_CAN_ACCRUAL_POINTS from SIEBEL.S_LOY_ACRL_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRIB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Cancellation';
    v_Tot_Earned_Points := v_TOT_AVAILABLE+v_TOT_PRDPTS_RDMD+v_TOT_PTS_EXP-v_CAN_ACCRUAL_POINTS;
    v_TOT_REDEEMED := v_TOT_PTS_RDMD-v_CAN_ACCRUAL_POINTS;
    DBMS_OUTPUT.PUT_LINE(' Total Earned: '|| v_Tot_Earned_Points || ' Total Redeemed: '|| v_TOT_REDEEMED || ' Total Expired: '|| v_TOT_PTS_EXP
    || ' Balance Points: '|| v_TOT_AVAILABLE || ' Tier Name: '|| v_TIER_NAME);
    select trunc(sysdate,'MONTH') INTO v_FIRST_DT from dual;
    va:= t_varray(Null,Null,Null,Null,Null,Null);
    FOR a in 1 .. 6 LOOP
    select trunc(last_day(v_FIRST_DT)) INTO v_LAST_DT from dual;
    SELECT SUM(AI.ACCRUALED_VALUE),SUM(AI.USED_VALUE) INTO v_ACCRUALED_VAL,v_USED_VAL from SIEBEL.S_LOY_ACRL_ITM AI,SIEBEL.S_LOY_ATTRDEFN A
    WHERE AI.MEMBER_ID = v_MEMBER_ID AND A.ROW_ID = AI.ATTRIB_DEFN_ID AND A.INTERNAL_NAME = 'Point 1 Value'
    AND trunc(AI.EXPIRATION_DT) >= v_FIRST_DT AND trunc(AI.EXPIRATION_DT) <= v_LAST_DT;
    V_EXPIRED_VAL := NVL(v_ACCRUALED_VAL-v_USED_VAL,0);
    va(a):=V_EXPIRED_VAL;
    v_FIRST_DT := add_months(v_FIRST_DT,1);
    End loop;
    END;
    end;
    Package declaration
    create or replace package Rewards_Summary_Package as
    TYPE t_varray IS VARRAY(6) OF NUMBER;
    PROCEDURE Rewards_Summary_Procedure
    (v_Tot_Earned_Points OUT NUMBER, v_TOT_REDEEMED OUT NUMBER, v_TOT_PTS_EXP OUT NUMBER,
    v_TOT_AVAILABLE OUT NUMBER, v_TIER_NAME OUT VARCHAR2,VA OUT t_varray,V_PR_CON_ID IN VARCHAR2);
    end;
    java code
    I had tried using java types and Oracle types
    conn=SiebelServiceDatasource.getConnection(SSBConstants.REWARDS_PROP_LOG_SUFIX);
    // ArrayDescriptor.TYPE_VARRAY
    ocstmt=(OracleCallableStatement)conn.prepareCall(" {call REWARDS_SUMMARY_PACKAGE.REWARDS_SUMMARY_PROCEDURE(?,?,?,?,?,?,?)}");
    //ocstmt=(OracleCallableStatement)conn.prepareCall(" call Test_Array(?,?)");
    ocstmt.registerOutParameter(1,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(2,OracleTypes.INTEGER);//1-616BH
    ocstmt.registerOutParameter(3,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(4,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(5,OracleTypes.VARCHAR);
    ocstmt.registerOutParameter(6,OracleTypes.ARRAY,"SIEBEL.T_VARRAY");
    ocstmt.setString(7,contactSiebelRowId);
    ocstmt.execute();
    Showing the following invalid name pattern SIEBEL.T_VARRAY
    Please help
    Thanks in advance
    Kiran

    create or replace package Rewards_Summary_Package as
        TYPE t_varray IS VARRAY(6) OF NUMBER;
    end;You've declared your type inside the package. You need to declare it as a SQL type, which is not part of a PL/SQL package.

  • Can you call a procedure inside another procedure and how many?

    Ok. I have 3 procedures. I would like to call 2 of the from inside one, but I would like them to be in order.
    So,
    procedure1 // this is in db1
         call procedure2
                this collects, and inserts data into table 2 from db1
                this must be run first
         call procedure3
               this update the table1, and table2 from db2, and db3
               this must be run second
         finish procedure1
               this also updates table1 and table2 from db1 and db3
               this must be run third
    procedure1 end;or should I call a function
    procedures 2, and 3 have there own dblinks to other dbs to gather datat, procedure1 is in the same db.
    the procedures dont have to be like above. If you want to run proc3, and call proc1, and proc2 first so be it. Just an example

    create or replace myPackage
    is
    procedure1;
    procedure2;
    procedure3;
    end myPackage;
    create or replace myPackage body
    is
      procedure1 is
      begin
        -- call 2
        procedure2;
        -- call 3
        procedure3;
      end procedure1;
      procedure2 is
      begin
        do_something_here;
      end procedure2;
      procedure3 is
      begin
        do_something_here;
      end procedure3;
    end myPackage;
    /* now run the procedure1 from sql*plus */
    execute myPackage.Procedure1;Message was edited by:
    Sven W. added packaged call

  • Can we call a transaction inside the same transaction?

    Hi all
    in my csae am facing this tricky situtation to do call the same transaction for bdc purpose would you please assist me can we do that either by calling it in any exits or by using any function modules ?

    What exactly are you trying to do?  Why not:
       loop at i_detail.
    your bdc code goes here ****
            perform bdc_transaction using xxxx.
      endloop.

  • How can we call windows application inside the bsp ...

    hi,
    i just want to call the exe file or execute or open outlook express inside a page...
    or.. openeing a notepad..
    thanks
    jaideep

    Check this thread..
    Call a Systemcommand from BSP
    how to call DLL in BSP
    <i>*Reward each useful answer</i>
    Raja T

  • Can't call a function inside another function

    Hello,
    i have the following function :
    FUNCTION test_day_week (P_DATE DATE)
    RETURN VARCHAR2 IS
    BEGIN
    RETURN TO_CHAR(P_DATE ,'DAY');
    END;
    --it returns the day name of a given date
    FUNCTION TEST_DAY_NUMBER (P_DAY_NAME VARCHAR2)
    RETURN NUMBER IS
         V_RESULT NUMBER;
         V_RETURN_DAY VARCHAR2(30);
         P_DATE DATE;
    BEGIN
    V_RETURN_DAY := test_day_week (P_DATE );
    MESSAGE('V_RETURN_DAY'|| V_RETURN_DAY);
    MESSAGE('V_RETURN_DAY'|| V_RETURN_DAY);
    IF V_RETURN_DAY = 'MONDAY' THEN V_RESULT :=1;
         END IF ;
    IF V_RETURN_DAY = 'TUSEDAY' THEN V_RESULT :=2;
         END IF ;
    IF V_RETURN_DAY = 'WENDSDAY' THEN V_RESULT :=3;
         END IF ;
    IF V_RETURN_DAY = 'THURSDAY' THEN V_RESULT :=4;
         END IF ;
    IF V_RETURN_DAY = 'FRIDAY' THEN V_RESULT :=5;
         END IF ;                
    IF V_RETURN_DAY = 'SATURDAY' THEN V_RESULT :=6;
    END IF ;
    IF V_RETURN_DAY = 'SUNDAY' THEN V_RESULT :=7;
         END IF ;
    RETURN V_RESULT;
    END;
    --The above function returnds the day name in numbers
    The proble is that when i call test_day_week function it returns no value even it is tested separatly and works fine don't know where is my problem :
    1-number of argrments in function[b] TEST_DAY_NUMBER
    ?? and so ..!
    Regards,
    Abdetu..

    You could also cut the whole thing down to a simple function... (assuming you have a need to customise your start of week rather than use built in date functionality)
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE FUNCTION test_day_week (P_DATE DATE) RETURN NUMBER IS
      2  BEGIN
      3    RETURN (INSTR('MONTUEWEDTHUFRISATSUN',TO_CHAR(P_DATE,'DY'))+2)/3;
      4* END;
    SQL> /
    Function created.
    SQL> select test_day_week(sysdate) from dual;
    TEST_DAY_WEEK(SYSDATE)
                         1
    SQL> select test_day_week(sysdate+1) from dual;
    TEST_DAY_WEEK(SYSDATE+1)
                           2
    SQL> select test_day_week(sysdate+2) from dual;
    TEST_DAY_WEEK(SYSDATE+2)
                           3
    SQL> select test_day_week(sysdate+3) from dual;
    TEST_DAY_WEEK(SYSDATE+3)
                           4
    SQL> select test_day_week(sysdate+4) from dual;
    TEST_DAY_WEEK(SYSDATE+4)
                           5
    SQL> select test_day_week(sysdate+5) from dual;
    TEST_DAY_WEEK(SYSDATE+5)
                           6
    SQL> select test_day_week(sysdate+6) from dual;
    TEST_DAY_WEEK(SYSDATE+6)
                           7
    SQL> select test_day_week(sysdate+7) from dual;
    TEST_DAY_WEEK(SYSDATE+7)
                           1
    SQL>

  • Can statements inside a package refer to database links

    Hi all
    I was just curious to know, what will happen in this case
    CREATE OR REPLACE PACKAGE BODY "TESTUSER"."TESTPKG" as
    procedure testproc is
    n number := 0;
    begin
    select count(*) into n from ps_tab@dblink;
    end;
    end testpkg;';
    Is it valid to have dblink inside a package body?
    Regards
    Edited by: user13332773 on Mar 6, 2011 10:26 PM

    user13332773 wrote:
    Hi all
    I was just curious to know, what will happen in this case
    CREATE OR REPLACE PACKAGE BODY "TESTUSER"."TESTPKG" as
    procedure testproc is
    n number := 0;
    begin
    select count(*) into n from ps_tab@dblnk;
    end;
    end testpkg;';
    Is it valid to have dblink inside a package body?
    RegardsSure it is. You can have a database link inside a package code. Moreover, you'll get the name of that database link in the REFERENCED_LINK_NAME column of the DBA_DEPENDENCIES view
    Kamran Agayev A.
    Oracle ACE
    My Oracle Video Tutorials - http://kamranagayev.wordpress.com/oracle-video-tutorials/

  • Calling native methods in a package

    Hi!
    We have a problem when calling native methods in a class which is in a package. As you can see from the code below we have a class making an instance of a class<testBando> which makes a instance of another class<Bando> which contains the native methods. When running the program we get the error:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: initialize
    at test2.Bando.initialize(Native Method)
    at test.testBando.<init>(testBando.java:10)
    at Main.main(Main.java:5)
    When we take the class that calls the native methods out of any package every thing works fine! Can you not call native methods inside a package or what are we doing wrong?
    // testBando.java
    package test;
    import test2.*;
    public class testBando {
    Bando b;
    public testBando() {
         b = new Bando();
         b.initialize();
    // Bando.java
    package test2;
    public class Bando {
    public native void initialize();
    static {
         System.loadLibrary("bando");
    // Main.java
    import test.*;
    public class Main {
    public static void main(String[] args) {
         new testBando();

    I suspect that your problem is that you have not
    regenerated the signature when you placed the native
    method's object in a package. Or same result but different sourc:
    -package name was changed and it wasn't regen'd
    -javah was run incorrectly (which gens the signatures with no package name.)

  • Can't access tables in PL/SQL package

    I'm trying to create my first package/stored procedure. Been to class, so I don't think the problem is with me. In a real environment now. My schema/user has access to tables in another schema, plus create procedure priviledges. I compiled the package spec OK, but couldn't use %Type. I had to specify the datatype. The package body won't compile with the error message "Error: PLS-00201: identifier 'PTI_PROD.SC_MSTR' must be declared". I can run the SQL just fine in SQL*Plus. Why can't I access tables inside a package. We didn't have this problem in class.

    steven. the oracle error msgs documentation says that maybe there is no access privelege to the table. this looks like a privelege issue. grant priveleges explicitly on those tables accessed by your procedure not through any roles.
    in your case login as pti_prod and type
    grant select,insert,update on sc_mstr to user1;
    this shld work.
    null

  • Calling a Function inside a procedure

    Can you call a function inside a procedure?...if so....how?

    Not all built-in functions can be used directly in an assignment.
    SQL> CREATE PROCEDURE p (p_val IN VARCHAR2) AS
      2  l_v VARCHAR2(10);
      3  BEGIN
      4     l_v := DECODE(p_val,'YES','TRUE','FALSE');
      5  END;
      6  /
    Warning: Procedure created with compilation errors.
    SQL> show error
    Errors for PROCEDURE P:
    LINE/COL ERROR
    4/4      PL/SQL: Statement ignored
    4/11     PLS-00204: function or pseudo-column 'DECODE' may be used inside
             a SQL statement onlyTTFN
    John

  • How can we call a class file of one package for class file of another

    How can we call a class file of one package from class file of another package and both packages exist in a same folder

    How can we call a class file of one package from
    class file of another package and both packages exist
    in a same folder
    Luckily they don't so it's really not a problem after all.

  • Can we call an ODI package from another ODI package within same Project?

    hi All,
    Can we call an ODI package from another ODI package within same Project?

    What you can do is get all the interfaces on the old package that you want to be included in the new package. This way, the new package will have the exact code from the old package.Or generate a scenario out of your ("old") package and drag&drop the scenario in the "new" package.
    That seems easier to me, because you can re-use the scenario as often as you want.
    But you have to take care: If you change your original ("old") package, you have to regenerate the scenario, otherwise the changes do not affect the scenario.
    Edited by: h_elmu_t on 02.07.2009 08:50

  • Bind variable inside a package

    Can we declare a bind variable inside a package specification?
    CREATE OR REPLACE PACKAGE GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE);
    VARIABLE O VARCHAR2(20);
    END GET_EMPLOYEEDETAILS ;
    CREATE OR REPLACE PACKAGE BODY GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE)
    IS
    BEGIN
    SELECT FIRST_NAME INTO F_NAME FROM EMPLOYEES WHERE EMPLOYEE_ID = E_ID;
    DBMS_OUTPUT.PUT_LINE(F_NAME);
    END;
    END GET_EMPLOYEEDETAILS;
    Output:
    ERROR at line 4: PLS-00103: Encountered the symbol "VARCHAR2" when expecting one of the following:
      := . ( @ % ; not null range default character
    The symbol ":=" was substituted for "VARCHAR2" to continue.
    2. IS
    3. PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE);
    4. VARIABLE O VARCHAR2(20);
    5. END GET_EMPLOYEEDETAILS ;
    6. /
    or is there any alternative for bind variables inside an package
    Thanks in advance
    Message was edited by: 1009739

    The "VARIABLE O VARCHAR2(20);" syntax is the way SQLPlus declared bind variables - it is specific to the client. Because PL/SQL packages and procedures are server code that continue past sessions, its only access to the client environment is what the client gives it - it can't go and create a bind variable in the client.
    PL/SQL procedures, functions and packages run from lots of environments, so they cannot access bind variables inside their body - you have to pass any external variables as parameters.
    Anonymous PL/SQL blocks can access bind variables.
    You can declare package public global variables - just leave out that "VARIABLE". E.g.
    CREATE OR REPLACE PACKAGE GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMP.EMPNO%TYPE, F_NAME OUT EMP.ENAME%TYPE);
    O VARCHAR2(20);
    END GET_EMPLOYEEDETAILS ;
    For local variables in your procedure, just put them between the IS and BEGIN. Using them in SQL inside the PL/SQL automatically uses them as a bind variable.
    create or replace PROCEDURE GET_FIRSTNAME(E_ID IN EMP.EMPNO%TYPE, F_NAME OUT EMP.ENAME%TYPE)
    IS
      O VARCHAR2(20);
      O2 VARCHAR2(21);
    BEGIN
      O := 'FR%';
    SELECT ENAME INTO F_NAME FROM EMP WHERE EMPNO = E_ID and ENAME like O;
    O2 := F_NAME || '2';
    DBMS_OUTPUT.PUT_LINE(F_NAME);
    END;
    O is bound in the query.
    To access bind variables from anonymous PL/SQL, first declare them in the calling environment. In SQL Plus that's
    VARIABLE O VARCHAR2(20);
    In Pro*C it's
    EXEC SQL BEGIN DECLARE SECTION;
      char[21] O
    EXEC SQL END DECLARE SECTION;
    Then reference it in anonymous PL/SQL with a colon as prefix:
    BEGIN
    SELECT FIRST_NAME INTO :O FROM EMPLOYEES WHERE EMPLOYEE_ID = E_ID;
    END;
    This only works for anonymous blocks (starting with BEGIN or DECLARE). As I said, PL/SQL procedures, functions and packages cannot see bind variables from the calling environment

Maybe you are looking for

  • How can a hyperlink in a table load an image in a new page?

    Hello, I�m using Java Studion Creator 2 Update 1 an I have following problem: In my jsp-page (main.jsp) I have a table component with an image hyperlink (showOriginal) in the first column and a hyperlink to another page in the second. On this page is

  • Suggestions for new kernel domain name

    i'm unsure if this the correct place to post this if not moderate away and i apologize: I am working on a new patchset for the linux kernel and its becoming a larger project that is *no* longer just a git repository.  I have been brainstorming ideas

  • How to open documents by default with Pages 4 ( "Change All", "Open With" info option)?

    Hello I installed Pages 5, which I don't like. So I would like to open all my documents by default with Pages 4. However, I can't get the system to fix this default. In the "Info" panel of the Finder, under "Open With", I can set Pages 4 as a default

  • Check this error (urgent)

    hai SDNs.. i have a problem... DATA: lt_doc TYPE tt_doc,       lt_final TYPE tt_final.   PERFORM fr_get_data_from_mseg CHANGING lt_doc . from this sub routine i am getting values into lt_doc   perform fr_final_output_data changing lt_final. i am usin

  • HT201441 why can't my iphone4s be statr

    what can i do?