Problem in my package procedure in a select query

    PROCEDURE PROCESS_ROW( P_Event             IN VARCHAR2,
                           P_Old_Record_Key    IN VARCHAR2,
                           P_Ledger_Id         IN VARCHAR2,
                           P_Reference         IN VARCHAR2,
                           P_Fund              IN VARCHAR2) IS
    l_cash_txn_id   PF_CASH_TXNS.CASH_TXN_ID%TYPE;
    l_client_id     PF_CASH_TXNS.CLIENT_ID%TYPE;
    l_plan_id       PF_CASH_TXNS.PLAN_ID%TYPE;
    l_account       VARCHAR2(1);
    l_plan_id       VARCHAR2(100);
    BEGIN
        l_cash_txn_id := P_Ledger_Id;
        l_client_id := SUBSTR(P_Reference, -6);
        l_account := SUBSTR(P_Reference, 1, 1); -- Get first letter of reference code, this is the account type.
        SELECT PLAN_ID INTO l_plan_id FROM INTEGRATION.MAPPING WHERE account = l_account;
    END PROCESS_ROW;The problem is at this line:
SELECT PLAN_ID INTO l_plan_id FROM INTEGRATION.MAPPING WHERE account = l_account;
The error(s) I'm getting is:
PLS-00371: at most one declaration for 'L_PLAN_ID' is permitted
PL/SQL: ORA-00904: : invalid identifier
The INTEGRATION.MAPPING table is currently empty, I'm not sure if this would have anything to do with it?

Should be more or less self-explanatory:
In your first question, the code sample shows that you've declared L_PLAN_ID twice and the error message states:
"PLS-00371: at most one declaration for 'L_PLAN_ID' is permitted"
So, although datatype or length for your variables may differ, you still cannot use the same name for a variable more than once in a PL/SQL block.

Similar Messages

  • Can we get data return from stored procedure in a select query ?

    Hello,
    Suppose i have a function GetSum(x,y) that returns sum of two numbers x and y .We can call this function from within a sql function like this :
    select GetSum(4,5) SUM from dual;But is this possible through a stored procedure ? i.e., can i call a stored procedure from within a select query like i have done in above code ?

    Hi,
    bootstrap wrote:
    Hello,
    Suppose i have a function GetSum(x,y) that returns sum of two numbers x and y .We can call this function from within a sql function like this :
    select GetSum(4,5) SUM from dual;But is this possible through a stored procedure ? i.e., can i call a stored procedure from within a select query like i have done in above code ?The short answer has already been given.
    Why can't you use a function?
    Suppose you could use a procedure. What results would you want to see from:
    SELECT  my_proc (4, 5)
    FROM    dual
    ;? Why?
    Explain what you want to do, and somebody will help you find a good way to do it.

  • PACKAGE SIZE n in SELECT query

    Hi,
    When using PACKAGE SIZE n option with SELECT queries, how to determine the best/optimum value of n ? Especially when we use this for querying tables like EKPO, EKKO etc.
    Regards,
    Anand.

    > When using PACKAGE SIZE n option with SELECT queries, how to determine the best/optimum value of n ?
    The 'package size' option to the select specifies how many
    rows are returned in one chunk.
    According to ABAP-Doku, it is best to use it with an internal table:
    DATA: itab TYPE STANDARD TABLE OF SCARR WITH NON-UNIQUE
                     DEFAULT KEY INITIAL SIZE 10.
    FIELD-SYMBOLS: <FS> TYPE scarr.
    SELECT * INTO TABLE itab PACKAGE SIZE 20 FROM scarr.
      LOOP AT itab ASSIGNING <FS>.
        WRITE: / <FS>-carrid, <FS>-carrname.
      ENDLOOP.
    ENDSELECT.
    But, basically, your application's requirements determine
    what's the best value for n.
    If you don't want a lot of DB-access, you choose a high
    value for n. If you don't want a lot of data in memory, you adjust it to a lower value.
    You can also use the 'up to n rows' construct in the select to limit the number of rows fetched from the db.
    thomas

  • PROBLEM WITH MY DATE BETWEEN CLAUSE IN SELECT QUERY

    WHEN I RUN THE CODE IT'S FETCHING DATA FROM 2007,2008,2009.
    SELECT ERDAT VBELN NETWR
    FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
    WHERE ERDAT BETWEEN '01.11.2008' AND '30.11.2008'.
    PLEASE GIVE ME A SOLUTION GUYS.

    Hi, Zubaer,
    Please Don't Use All Caps in Subject and Body Text too
    Have a look at [Rules of Engagement|https://www.sdn.sap.com/irj/scn/wiki?path=/display/home/rulesofEngagement]
    Under Heading
    - Use a Good Subject Line
    Do not use words in capital letters
    Use the following way. it will solve out your Problem,
    SELECT erdat vbeln netwr
    FROM vbrk INTO CORRESPONDING FIELDS OF TABLE it_vbrk
    WHERE erdat BETWEEN '20081101' AND '20081130'.
    Best Regards,
    Faisal

  • SELECT Query in a Procedure

    how do I create a procedure for a SELECT query like the following? When I create a procedure; I get an error "
    Error(80,1): PLS-00428: an INTO clause is expected in this SELECT statement"
    PROCEDURE  MyProc
    IS
    BEGIN
    select 'Dakota' as ALIAS
          ,A.StartDate
          ,B.EndDate
    from Customer A
        ,Clients b
    where  a.cType = b.cType
    and b.Active =0
    ORDER BY StartDate, EndDate
    END  MyProc;

    I get an error:
    Error(4,29): PLS-00103: Encountered the symbol "SYS_REFCURSOR" when expecting one of the following: := . ) , @ % default character The symbol ":=" was substituted for "SYS_REFCURSOR" to continue. 
    Package:
    PROCEDURE  MyProc(c out OUT SYS_REFCURSOR)
    Package Body:
    PROCEDURE  MyProc(c out OUT SYS_REFCURSOR)
    IS
    BEGIN
      open c for
                select 'Dakota' as ALIAS
                            ,A.StartDate
                            ,B.EndDate
                from Customer A,Clients b
                where  a.cType = b.cType
                     and b.Active =0
                ORDER BY StartDate, EndDate;
    END  MyProc;

  • Package Procedure

    Problem calling a package procedure with default values within oracle forms 6i. It appears that
    oralce forms 6i does not support calls to package procedure with default values.
    Any ideas why???
    Much appreciated.

    There are no gobal variables within the package. It's actually the package procedures that use default values.
    These package procedure are being called from different calling environments and I want to avoid overloading the procedures.
    So if I set the parameters that are not used by forms6i to default values, I'd have hoped it worked but it didn't.

  • Need help in optimisation for a select query on a large table

    Hi Gurus
    Please help in optimising the code. It takes 1 hr for 3-4000 records. Its very slow.
    My Select is reading from a table which contains 10 Million records.
    I am writing the select on large table and Retrieving the values from large tables by comparing my table which has 3-4 k records.
    I am pasting the code. please help
    Data: wa_i_tab1 type tys_tg_1 .
    DATA: i_tab TYPE STANDARD TABLE OF tys_tg_1.
    Data : wa_result_pkg type tys_tg_1,
    wa_result_pkg1 type tys_tg_1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1 from
    /BIC/PZREB_SDAT *******************THIS TABLE CONTAINS 10 MILLION RECORDS
    into CORRESPONDING FIELDS OF table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE***************CONTAINS 3000-4000 RECORDS
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE-/BIC/ZLITEM1.
    sort RESULT_PACKAGE by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    sort i_tab by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    loop at RESULT_PACKAGE into wa_result_pkg.
    read TABLE i_tab INTO wa_i_tab1 with key
    /BIC/ZREB_SDAT =
    wa_result_pkg-/BIC/ZREB_SDAT
    AGREEMENT = wa_result_pkg-AGREEMENT
    /BIC/ZLITEM1 = wa_result_pkg-/BIC/ZLITEM1.
    IF SY-SUBRC = 0.
    move wa_i_tab1-/BIC/ZSETLRUN to
    wa_result_pkg-/BIC/ZSETLRUN.
    wa_result_pkg1-/BIC/ZSETLRUN = wa_result_pkg-/BIC/ZSETLRUN.
    modify RESULT_PACKAGE from wa_result_pkg1
    TRANSPORTING /BIC/ZSETLRUN.
    ENDIF.
    CLEAR: wa_i_tab1,wa_result_pkg1,wa_result_pkg.
    endloop.

    Hi,
    1) RESULT_PACKAGE internal table contains any duplicate records or not bassed on the where condotion like below
    2) Remove the into CORRESPONDING FIELDS OF table instead of that into table use.
    refer the below code is
    RESULT_PACKAGE1[] = RESULT_PACKAGE[].
    sort RESULT_PACKAGE1 by /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    delete adjustant duplicate form RESULT_PACKAGE1 comparing /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1
    from /BIC/PZREB_SDAT
    into table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE1
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE1-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE1-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE1-/BIC/ZLITEM1.
    and one more thing your getting 10 million records so use package size in you select query.
    Refer the following link also For All Entry for 1 Million Records
    Regards,
    Dhina..
    Edited by: Dhina DMD on Sep 15, 2011 7:17 AM

  • Regarding nor of line items selected in per select query..

    hi,
    i want  to display nor of line items selected in per select query for two individual  queries which are linkesd by for all entries..
    regards..
    chetan

    Hi,
    I dont unserstand the problem you are facing. please paste your SELECT query and then explain the problem. then it will be easy for analysis.
    Basically DESCRIBE TABLE itab LINES n.  this statement will put the number of lines the internal table contains
    //Kothand

  • Select Query on BSEG

    SELECT bukrs
             belnr
             gjahr
             augdt
             bschl
             koart
             umsks
             shkzg
             hkont
             kostl
             aufnr
             projk
             xref1
             wrbtr
             dmbtr
             ebeln
             ebelp
             lifnr
             sgtxt
        INTO TABLE t_bseg1
        FROM bseg FOR ALL ENTRIES IN payd
       WHERE bukrs EQ payd-zbukr
         AND belnr EQ payd-belnr
         AND gjahr EQ payd-gjahr
        AND koart IN ('K','S').
    The above query does not bring me all the records for a particular BELNR.
    However when i See in BSEG table through SE16 i found 4 records, but when i retrieve them through the above wuery it brings only three records.
    ANy idea, what can i do to get the 4th record as well.. I checked the primary keys they are all same for all the 4 records in the DB table.
    Regards

    Hi Sam,
    You were not fetching all the primary keys from the table and hence the problem comes.
    Add BUZEI in the select query and try.
    SELECT bukrs
    belnr
    gjahr
    *BUZEI*
    augdt
    bschl
    koart
    umsks
    shkzg
    hkont
    kostl
    aufnr
    projk
    xref1
    wrbtr
    dmbtr
    ebeln
    ebelp
    lifnr
    sgtxt
    INTO TABLE t_bseg1
    FROM bseg FOR ALL ENTRIES IN payd
    WHERE bukrs EQ payd-zbukr
    AND belnr EQ payd-belnr
    AND gjahr EQ payd-gjahr
    AND koart IN ('K','S').
    Hope this solves!!!
    Regards.
    Ganga

  • Error while accessing oracle packaged procedure in crystal report./ How to

    Hi,
    When i tried to call a packaged procedure in crystal reports for .net, i am unable to access it.
    i am getting error as 'unknown query engine'
    In that packaged procedure i have a two IN parameters and one OUT TABLE parameter ( which is declared in package specification )
    And when selecting the packaged procedure in crystal report,the wizard shows all the parameters like the IN parameters, and when i just leave it blank. i unable to set into report.
    ie., the OUT table type is shown as IN paramters (Actually it is an output and has field fields in it.)
    And No fields are coming in the Fields Explorer of crystal reports in .net.
    can you provide any help.
    thanks and regards
    Mohan Raj K.
    Actually using vs.net 2005 prof.
    Message was edited by:
    mohanraj_k

    Actually the OUT Parameter type in the stored
    procedure is showing as IN Parameters and asking
    for input values in the crystal report creation
    wizard(while selecting the
    database,connection,storedprocedures/qualifiers).That sounds like a problem on the .net / crystal report creation wizard side of things. Oracle no doubt recognises them as OUT parameters, so it's not Oracle at fault. I would guess the .net stuff is just querying the data dictionary to see what parameters there are rather than differentiating between the INs and OUTs.

  • Package/procedure name

    Hi,
    what is the package/procedure name that helps to run sql statement.
    I hope DBMS_SQL is the package that helps to run sql statemanet in oracle.
    Please correct me if i am wrong....
    Thanks

    Murali wrote:
    Hi,
    I just want to know which package helps to run sql statement in oracle.
    Thanks.There is no package that runs all SQL in Oracle. SQL is executed through the basic Oracle software. DBMS_SQL will run dynamic SQL but dynamic SQL is seldom needed and when it is needed there are usually easier ways to do it - usually reference cursors or EXECUTE IMMEDIATE. For selects DBMS_SQL requires a LOT more work than the other two methods: you have to define the select fields, define the query (the other methods require this step), create variables to hold the results, parse the sql, and execute the SQL.
    Reasons to use DBMS_SQL are when the other methods of dynamic SQL won't work
    * result set from query is unknown at run time (which may be a design problem)
    * generated SQL statements is > 32K, longer than PL/SQL supports for a text value (again, design needs to be considered)

  • Ability to filter out Views, Indexes, Packages, Procedures, Functions, etc.

    Under Connections, I choose my database, then the user, and from there I view my Tables. I have no need to view Views, Indexes, Packages, Procedures, etc., just the tables (which I am able to filter).
    Since the tree containing Views, Indexes, Packages, etc., take up a lot of real estate (I work with multiple databases, each with a specific user, or schema), is it not possible to filter these out?
    Thanks!
    Edited by: user9956988 on Jun 15, 2010 3:53 PM

    Just to double check that I'm interpreting the problem correctly, is the following true:
    select * from all_objects where object_name = 'DBA_SOURCE'
    returns nothing
    select * from dba_source where name = your PL/SQL module
    returns all the code

  • 942: error when trying to browse/refresh Packages, Procedures and Functions

    Hi,
    I'm using OSD 1.1 against 10g.
    I can create and compile functions in a certain schema but when I try to browse the Functions node I get "ORA-00942: table or view does not exist." and the node does not expand.
    The same thing happens with the Packages and Procedures nodes.
    Does anyone have any ideas?
    Thanks in advance
    Mike

    I've got the same problem with SQL Developer 1.1.0.23.64 against 9.2.0.4.0 and 10.1.0.4.0. This error occured only for a few package/procedure/function owners. I've found that these owners have SELECT ANY TABLE system privilege. In such case SQL Developer generates following SELECT:
    SELECT OBJECT_NAME, OBJECT_ID, DECODE(STATUS, 'INVALID', 'TRUE', 'FALSE') INVALID, 'TRUE' runnable, NVL( b.HAS_BODY, 'FALSE') HAS_BODY
    FROM SYS.DBA_OBJECTS a,
    (SELECT 'TRUE' HAS_BODY, object_name tmp_name FROM SYS.DBA_OBJECTS WHERE OWNER = :SCHEMA AND OBJECT_TYPE = 'PACKAGE BODY') b
    WHERE OWNER = :SCHEMA
    AND OBJECT_TYPE = 'PACKAGE'
    AND object_name = tmp_name (+)
    AND SUBOBJECT_NAME IS NULL
    AND OBJECT_ID NOT IN ( SELECT PURGE_OBJECT FROM RECYCLEBIN )
    Otherwise it generates
    SELECT OBJECT_NAME, OBJECT_ID, DECODE(STATUS, 'INVALID', 'TRUE', 'FALSE') INVALID, 'TRUE' runnable, NVL( b.HAS_BODY, 'FALSE') HAS_BODY
    FROM SYS.ALL_OBJECTS a,
    (SELECT 'TRUE' HAS_BODY, object_name tmp_name FROM SYS.ALL_OBJECTS WHERE OWNER = :SCHEMA AND OBJECT_TYPE = 'PACKAGE BODY') b
    WHERE OWNER = :SCHEMA
    AND OBJECT_TYPE = 'PACKAGE'
    AND object_name = tmp_name (+)
    AND SUBOBJECT_NAME IS NULL
    AND OBJECT_ID NOT IN ( SELECT PURGE_OBJECT FROM RECYCLEBIN )
    Both for 10g.
    So you could try to grant SELECT on DBA_OBJECTS to owner of your functions.
    I don't know why SQL Developer doesn't SELECT from ALL_OBJECTS in all cases.
    Jiri
    Message was edited by:
    Jiri Suchy
    You will need grant SELECT on DBA_SOURCE, too.

  • Error Executing Oracle Package/Procedure

    I'm having trouble executing a procedure in a package of mine. I have a package in one schema I'm trying to execute it with a different ID (i.e. User1 in trying to execute a procedure in User2's Schema). The permissions look fine (Execute has been granted), but when I try to exec the procedure using "Schema.Package.Procedure" format, I get a "component 'PackageName' must be declared" error. If I create a Public Synonym for my package and exec my Procedure, dropping the Schema Prefix ("Package.Procedure"), it executes fine. To make things even more interesting, I recreated the packages in a third Schema and executedfine with the Schema prefix ("Schema.Package.Procedure").
    The only difference (I see) between the two schemas is the use of an "underscore" in the name: (for example) Schema1 and Schema_Two. Put the package in Schema1 and it runs fine. Put it in Schema_Two and it errors when fully qualified with the Schema name.
    Does Oracle have a problem running packages when the Owner Schema has an underscore in the name? Or am I missing some other potential problem(s)?
    Thanks in advance...

    355099: I do have another copy of this procedure in another Schema. I'll try dropping that other version.
    Mark: We have a schema for our data/logic and an ID we created for the web (so we don't access our data using our Schema Owner ID). The web ID is granted Select authority to Tables and Execute authority to Packages. We use this technique in other applications and it works fine. Those permissions have been set here but we still have the issue. I'll keep digging around. I'm sure it's something minor we are overlooking.
    Thanks for you replies...

  • Error While Creating Block on Package Procedure

    Hi
    When I try to create a block on a package Procedure I get the following error
    ifbld60.exe has generated errors and will be closed by Windows.
    You will need to restart the program.
    An Error log is being created,
    and forms closes.
    Is it something to do with Forms problem or with Windows? Is there a patch available for this problem or its a OS bug. The client I am testing this form from is Windows 2000 Professional.
    Thanks for your help
    Diogo

    Hi
    You cannot directly insert object in Stored Procedure universe,Whatever object you are using to define your derived table,you have to include all those objects into the universe first.
    From the below image you can see that i have 3 derived tables ,but whatever objects i am trying to use all those i have inserted into the universe.
    Try to build like this save and export.
    Let me know if you face nay error

Maybe you are looking for