So many Input parameter in stored procedure..how to handle it ?

Hello,
I have one stored procedure.in that,there is around *600 input parameter*.now I am writing one by one input parameter and this is looking very time consuming for me.is there any other method to solve it.can we use Ref cursor or any thing else...??if yes,then please explain me with one example....I have no so much idea about ref cursor.
Thanks

It would be pretty stupid, in any language, to define a method/procedure/function that has a 600 parameter signature.
There are a number of ways to address this - correctly. And these have already been suggested:
- define proper data structures for these parameters
- use arrays
As for how to address this in PL/SQL, depends entirely on how the call interface from the client looks like and is capable of.
For example, if this is from a web page and the call is made via mod_plsql, the flexible 2 parameter call interface should be used. The procedure will have 2 parameters. The caller will pass name-values. The 1st array will contain the names (e.g. 600 names). The 2nd array will contain the values (e.g. 600 values).
If the caller is a Java for example, then advance user define/custom SQL types can be defined in Oracle, used and populated in Java, and then pass to PL/SQL.
Let's say the caller is pretty dumb and does not support the object features in the OCI (OCI = the Oracle client driver call interface used by the client).
In that case you do not want a 600 parameter procedure.. but you still need to get the data into that Oracle server session in order to execute PL/SQL code in that session to crunch that data. A flexible and scalable solution would be to define a GTT - a global temp table (done once off up front in that schema). This allows the client to insert rows in that temp table that can be seen by that session's PL/SQL code only. For performance, the client can create a standard client array for the 600 parameters and call the SQL insert using array binding.
This results in a single insert call to Oracle. Accompanied with 600 values. Oracle executes that insert 600 times. You know have 600 rows in the GTT and the next client call to Oracle instructs the PL/SQL procedure to process the contents of the GTT.

Similar Messages

  • Passing UDT TABLE of VARCHAR as an Input parameter in Stored procedure call from java

    I have following Type defined at the schema: ident_arr IS TABLE OF VARCHAR2(100) which is type of one of the input parameters. I am able to create oracle.sql.ARRAY object to map it with this UDT before calling my stored procedure from java. When I execute my stored procedure, I get the following error:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'P_PV_WCC_INSERT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    I have already checked all other parameter types.

    Hello,
    Thank you, guys, for advice. I should have explained calling context before, but what I basically need to do is to see if procedure(arg1, list(record(arg2, arg3))) returns true.
    I see array binding wouldn't fit there nicely. Internal procedure calls would be proc(next(arg1), next(arg2), next(arg3)) - if all these return true, external call should also return true. I would need to make a list of repeating values of arg1 and separate list(record(arg2, arg3)) into separate lists. I would also need to record whether the internal call returns true to deduce whether external call returns true.
    As I see no better way yet, I'll make Oracle procedure proc(arg1, arg2, arg3) and implement a loop in .NET side. If I optimize for performance, I'll probably pack the array of records into string and pass it for Oracle side to parse.
    Regards,
    Aurimas Pranskevicius

  • Passing parameter into stored procedure

    Hi guys,
    I have a big problem here passing as a parameter in stored
    procedure.
    If i pass as a parameter in where clause it is working fine.
    Whenever i pass the parameter in order by it was not working..
    How to implement this issue????
    Here i am giving the example for package:
    PACKAGE XTRA.TEST_STATUS
    AS
    TYPE GenericCurTyp IS REF CURSOR;
    PROCEDURE SP_MAIN
    ( insortgroup IN VARCHAR2,GENERAL_CUR IN OUT GenericCurTyp);
    END TEST_STATUS;
    PACKAGE BODY XTRA.TEST_STATUS
    AS
    PROCEDURE SP_MAIN
    ( insortgroup IN VARCHAR2, GENERAL_CUR IN OUT GenericCurTyp
    ) AS
    BEGIN
    OPEN GENERAL_CUR FOR
    select last_name,first_name from applicant Order By insortgroup;
    END SP_MAIN;
    END TEST_STATUS;
    Passing as a parameter i am getting the below details.
    LAST_NAME FIRST_NAME
    ASFSDAF DASDFASF
    Ad DASD
    Adams John
    DANA WITEST
    If i hot code the parameter insortgroup to last_name
    i am getting the below values:
    LAST_NAME FIRST_NAME
    'ANNUNZIO GIANCOLA GABRIEL
    0'BRIEN ARMA
    0120453EZ ESTANISLAO
    082479 ELIZABETH
    Thanks,
    Rao

    CREATE OR REPLACE PACKAGE xtra.test_status
    AS
      TYPE GenericCurTyp IS REF CURSOR;
      PROCEDURE sp_main
        (insortgroup IN     VARCHAR2,
         general_cur IN OUT GenericCurTyp);
    END test_status;
    CREATE OR REPLACE PACKAGE BODY xtra.test_status
    AS
      PROCEDURE sp_main
        (insortgroup IN     VARCHAR2,
         general_cur IN OUT GenericCurTyp)
      AS
        select_statement VARCHAR2 (4000) := NULL;
      BEGIN
        select_statement :=
        'SELECT   last_name,
                  first_name
         FROM     applicant
         ORDER BY ' || insortgroup;
        DBMS_OUTPUT.PUT_LINE (select_statement);
        OPEN general_cur FOR select_statement;
      END sp_main;
    END test_status;

  • Pass a date parameter to Stored Procedure

    Hello friends,
    Can you help to pass a date parameter to Stored procedure from JSP. This is my code:
    In Oracle 9i I have this:
    PROCEDURE SP_EDORES(
    pfechaini IN hist_pol_reclama.hrc_fecha_contabilidad%Type, <-- This is a date field
    pfechafin IN hist_pol_reclama.hrc_fecha_contabilidad%Type, <-- This is a date field
    p_recordset OUT PKG_REP_CIERRE.cursor_type) AS
    In JSP have this:
    CallableStatement stmt = (CallableStatement)conn.prepareCall( "begin PKG_REP_CIERRE.SP_EDORES(?,?,?); end;" );
    stmt.registerOutParameter(3,oracle.jdbc.driver.OracleTypes.CURSOR);
    stmt.setDate(1,Date.valueOf("01-06-2005"));
    stmt.setDate(2,Date.valueOf("30-06-2005"));
    ResultSet rset = (ResultSet)stmt.getObject(3);
    while (rset.next()) {
    %>
    <TR>
    <TD ALIGN=CENTER> <%= rset.getString(1) %> </TD>
    <TD ALIGN=CENTER> <%= rset.getString(2) %> </TD>
    <TD ALIGN=CENTER> <%= rset.getString(3) %> </TD>
    <TD ALIGN=CENTER> <%= rset.getInt(4) %> </TD>
    </TR>
    <%
    The Stored Procedure returns de Result set, however I think does not recognized the date format because I need it with this format dd-mm-yyyy.
    Thanks in advance

    to use Date you will need the oracle package.
    u can try this other solution: use String, not Date
    CallableStatement stmt = (CallableStatement)conn.prepareCall( "begin PKG_REP_CIERRE.SP_EDORES(?,?,?); end;" );
    stmt.registerOutParameter(3,oracle.jdbc.driver.OracleTypes.CURSOR);
    stmt.setString(1,"01-06-2005");
    stmt.setString(2,"30-06-2005");
    ResultSet rset = (ResultSet)stmt.getObject(3);
    while (rset.next()) {
    %>
    if this don't work you can change your PL/SQL to get Strings and do the conversion with TO_DATE in the sql statement.

  • Return a parameter through stored procedures

    Hello Experts
    I want to return parameter through stored procedures so as to ensure that the application has been executed properly.
    My source message format is
    <StatementName5>
    <storedProcedureName action=u201D EXECUTEu201D>
      <table>Summarize_prc</table>
    <empid  [isInput=u201Dtrueu201D] [isOutput=true] type=SQLDatatype>val1</empid>
    </storedProcedureName > 
    </StatementName5>
    Do i need to put some extra parameters for return values from the stored procedures?
    What would be the response message format to return the parameters from stored procedure.
    Thanks
    Sabyasachi

    Hi,
    If you wants to read the return values from stored procedure, the scanario should be designed as Sync.
    The format looks like thsi
    <Message Type Name>
          <STATEMENTNAME_response>
                      <Field1> </Field1>
       </STATEMENTNAME_response>
    </Message Type Name>

  • Is it possible to pass TABLE as the output parameter in stored procedure

    Hey Experts,
      Is it possible to pass TABLE as the output parameter in stored procedure.
    eg
    create procedure spGetData
    @tableName as TABLE(intValue INT NOT NUL)
    as 

    You can use OPENQUERY or OPENROWSET, as mentioned above, to make stored procedure results table like. There are
    some limitations with these methods:
    http://technet.microsoft.com/en-us/library/ms188427.aspx
    In OPENQUERY this-sql-server-instance can be used instead of a linked server name. It requires setting data accces server option:
    exec sp_serveroption @server = 'PRODSVR\SQL2012'
    ,@optname = 'DATA ACCESS'
    ,@optvalue = 'TRUE'
    LINK: http://www.sqlusa.com/bestpractices/select-into/
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • REF CURSOR as IN parameter to stored procedure

    Currently, ODP.NET supports REF CURSOR parameter as OUT parameter only.
    Based on the project requirements it is necessary to pass
    multiple records to the stored procedure.
    In this case REF CURSOR as IN parameter is useful.
    What are the plans to implement REF CURSOR as IN parameter to stored procedure?
    What is the work around in case it is necessary to pass several different
    record types as arrays to stored procedure?

    ODP.NET does not limit REF Cursor parameters to IN parameters. This is a known PL/SQL limitation.
    An excerpt from Application Developer's Guide:
    "If you pass a host cursor variable to PL/SQL, you cannot fetch from it on the server side unless you also open it there on the same server call".

  • IN amount of FI document input the  wrong profit center,how to handle it?

    Dear everyone
    IN amount of FI document input the  wrong profit center,how to handle it? Transfer one profit to another or how to do it ?
    Thanks,
    Doris
    Cross-post

    Hi,
    Are you using NEW GL or EC-PCA? If New GL, you can do manual adjustment (FI entry). If EC-PCA, you can do it using 9KE0.

  • How to pass RECORD input type to stored procedure from JDBC?

    Hi,
    We have stored procedure which takes RECORD as input .
    We could execute the below script from oracle client tool and get the response.
    declare
    l_record app.batch_update.add_record;
    l_id number;
    begin
    -- memberNumber
    l_record.no := '123456700';
    -- Policy Number
    l_record.pno := '1234567'
    -- Status. This will always be NEW.
    -- Call to API to add record
    app.batch_update.add_request
    (p_record => l_record,
    p_id => l_id,
    end;
    We have requirement to construct RECORD input from Java application and pass it to callable statement.
    We have tried to construct it via STRUCT and pass it to callable statement but it didn't work.
    We have constructed it like the following but not sure whether it is correct. It was throwing error "java.sql.SQLException: invalid name pattern: app.batch_update.add_record
    StructDescriptor structdesc = StructDescriptor.createDescriptor
    ("app.batch_update.add_record", delConn);
    Object[] p1obj = {' 12345','124050'};
    STRUCT p1struct = new STRUCT(structdesc, delConn, p1obj);
    Not sure whether I am doing the logic correctly.
    Please point me to the correct approach.
    Thanks in Advice
    Thanks

    Wrap the method using a record-type parameter in PL/SQL; a simplified example follows. Add exception handling, translation of types etc. as needed.
    CREATE OR REPLACE PROCEDURE prc_wrap_prc_using_rec
    pv_my_field_01 IN VARCHAR2,
    pv_my_field_02 IN VARCHAR2,
    pv_my_field_99 IN VARCHAR2,
    pv_err_msg OUT VARCHAR2
    ) AS
    -- Non-scalar parameter
    pr_my_record user.pkg_rec_declarations.wr_a_record_decl;
    BEGIN
    -- Load the work record
    pr_my_record.pv_field_01 := pv_my_field_1;
    pr_my_record.pv_field_02 := pv_my_field_2;
    pr_my_record.pv_field_99 := pv_my_field_99;
    -- Call the procedure
    pkg_std_routines.prc_do_sumfin(pr_my_record, pv_err_msg);
    END;

  • How to pass refcursor as input parameter to a procedure in a package

    Hi there
    Please can anybody explain me with an small example for
    passing a procedure output(output should be a refcursor) and pass that refcursor values into a procedure in a package as input parameter and this value i want to use as join condition in my procedure ie. ename=refcursor.ename like this).That my exact question is how to pass refcursor values as in parameter
    Pls suggest me with some example statements
    thanks in advance
    prasanth a.s.

    I am giving you a generic example.
    SQL> variable v_out REFCURSOR
    SQL> r
      1  DECLARE
      2  PROCEDURE TEST1(p_out OUT SYS_REFCURSOR) IS
      3  BEGIN
      4  OPEN p_out FOR SELECT EMPNO,ENAME FROM SCOTT.EMP;
      5  END;
      6  PROCEDURE TEST2(p_in IN SYS_REFCURSOR) IS
      7  v_empno NUMBER(10);
      8  v_ename VARCHAR2(30);
      9  BEGIN
    10  LOOP
    11  FETCH p_in INTO v_empno,v_ename;
    12  EXIT WHEN p_in%NOTFOUND;
    13  DBMS_OUTPUT.PUT_LINE(v_ename);
    14  END LOOP;
    15  NULL;
    16  END;
    17  BEGIN
    18     TEST1(:v_out);
    19     TEST2(:v_out);
    20* END;
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    PL/SQL procedure successfully completed.

  • How to get RECORD data in output parameter of stored procedure

    I would like to return some data through RECORD structure from stored procedure.
    I have defined the RECORD as below:
    type ShipmentStatus is record(
    Booked integer,
    OnWater integer,
    OnRoad integer,
    InAir integer,
    OnRail integer,
    InWarehouse integer,
    Idle integer);
    the stored procedure is defined as
    create or replace procedure SP_MC_GET_SHIPMENT_STATUS
    iCustId in nvarchar2,
    oResult out ShipmentStatus
    I can get result in Sql*plus or PL/SQL developer, but I failed in get the result in Toplink.
    How can I get the output result, and convert it to an ENTITY by Toplink?
    Could you give me some advices on how to do mapping, how to call the stored procedure etc.., or code snip?
    Your answer is deeply appreciated. :)

    I'm not sure it is possible to get the PL/SQL record type through JDBC. Please try to access this procedure through JDBC to see if it is possible.
    You may need to convert the record type, to an object-type, i.e. wrap the procedure in another procedure that converts the record type. You could also just wrap the procedure in another that expands the record values into individual output parameters.

  • How to pass a CURSOR as an input in a Stored Procedure ?

    Hi all
    I am using Java to work with 2 Oracle DBs, using JDBC.
    I've got a question about using a Oracle Stored Procedure with CURSORs :
    A first stored procedure gets data from the first DB (returns a CURSOR) and I'd like to pass this CURSOR to the second stored procedure as a (Java) IN parameter, so using a "getObject()" then a "setObject()", to insert data from the CURSOR in the second DB.
    This is the theory !
    En reality, the first stored procedure works fine, and returns the cursor, but after that ... I can't even create the second stored procedure. I planed to do something like the following stuff :
    CREATE OR REPLACE PROCEDURE proc_insert_data(cur_ref IN OUT types.ref_cursor) AS
    BEGIN
    LOOP
    FETCH cur_ref INTO FIELD1, FIELD2;
         INSERT INTO TABLENAME VALUES (FIELD1, FIELD2);
    EXIT WHEN cur_ref%NotFound;
    END LOOP;
    END proc_insert_data;
    with a LOOP for each row and then an INSERT.
    But this doesn't seeem to be correct.
    Has anybody an idea to make this stored procedure to work ?
    Thx in advance
    Krystoffff

    Hi Chris,
    When you want to pass a CURSOR to a procedure/function
    you will have to employ a package here. Create a package
    which contains both of your procedures.This package should have a global variable which is of type ref cursor.The IN parameter for the 2nd procedure and the OUT parameter of the first proc should be of type this global cursor var.
    Now you call the first procedure and get the resulting cursor from it, pass it to the second procedure...
    Good luck.
    Regards,
    Madhu

  • How can I search for a string, as an input parameter to a procedure?

    Hi all,
    I need to solve one scenario. In this the search string and search against columns, both are passed as input parameters to a procedure. till now i didn't face this situation.. can you please help me in this by giving some sample code...
    Thanks in advance.
    Regards,
    Ramu.

    Maybe something like this then?
    SQL> CREATE OR REPLACE PROCEDURE EMP_SEARCH
      2  (
      3          pColumnName     IN VARCHAR2
      4  ,       pSearchParam    IN VARCHAR2
      5  ,       pResult         OUT SYS_REFCURSOR
      6  )
      7  AS
      8  BEGIN
      9          IF UPPER(pColumnName) = 'ENAME' THEN
    10                  OPEN pResult FOR
    11                          SELECT  ENAME
    12                          FROM    SCOTT.EMP
    13                          WHERE   ENAME LIKE '%' || pSearchParam || '%';
    14          ELSIF UPPER(pColumnName) = 'JOB' THEN
    15                  OPEN pResult FOR
    16                          SELECT  ENAME
    17                          FROM    SCOTT.EMP
    18                          WHERE   JOB LIKE '%' || pSearchParam || '%';
    19          ELSIF UPPER(pColumnName) = 'DEPTNO' THEN
    20                  OPEN pResult FOR
    21                          SELECT  ENAME
    22                          FROM    SCOTT.EMP
    23                          WHERE   DEPTNO LIKE '%' || pSearchParam || '%'
    24          END IF;
    25  END;
    26  /
    SP2-0804: Procedure created with compilation warnings
    SQL> VAR C REFCURSOR
    SQL> EXEC EMP_SEARCH('ENAME','SMITH',:c);
    PL/SQL procedure successfully completed.
    SQL> PRINT c;
    ENAME
    SMITH
    SQL> EXEC EMP_SEARCH('JOB','MANAGER',:c);
    PL/SQL procedure successfully completed.
    SQL> print c;
    ENAME
    JONES
    BLAKE
    CLARK
    SQL> EXEC EMP_SEARCH('DEPTNO','30',:c);
    PL/SQL procedure successfully completed.
    SQL> print c
    ENAME
    ALLEN
    WARD
    MARTIN
    BLAKE
    TURNER
    JAMES
    6 rows selected.Be careful though. If you have a large amount of data this search could take a long time because Oracle will not choose an indexed path. If that's an issue you should investigate using Oracle Text.
    HTH!
    Edited by: Centinul on Apr 26, 2010 7:36 AM

  • Check If Tables are being used in Stored Procedures & How many times !!

    Dear All,
    I want to make a script which can give me an answer, that If there is any table , then Whether It's using in any stored procedure or not ? If yes, then what the occurrence in procedures - means if table is "ABC" & Its being used in stored procedure
    "XYZ" then i want to know that its using 1 time, 2 time or more in particular procedure ..
    Pls Help

    just in-case if you want to get the Cross DB dependency
    i have extent Visakh16 code
    please use sql_modules to get the full definition of the DB Objects
    you can replace stg_table with your decided table, also use dbname.schemaname.tablename if you want to get  Cross DB dependency
    just came up with this from
    link
    create table #temp (
    dbname sysname,
    name sysname,
    Occurance int
    exec sp_MSforeachdb '
    use ?
    DECLARE @TableName varchar(100)
    SET @TableName = ''stg_table''
    insert into #temp
    SELECT db_name() ,name,(LEN(definition) - LEN(REPLACE(definition,'' '' + @TableName + '' '','''')))/LEN('' '' + @TableName + '' '') AS Occurance
    FROM sys.sql_modules m
    INNER JOIN sys.objects o
    ON o.object_id = m.object_id
    AND o.type = ''p''
    WHERE m.definition LIKE ''% '' + @TableName + '' %'''
    select *
    from #temp
    where dbname not in ('master','model','msdb','tempdb')
    order by 1,2
    Thanks
    Saravana Kumar C

  • Datetime parameter from stored procedure

    <p>I have a report written in CR10 which uses a stored procedure as the datasource. The stored procedure has 3 input parameters, two of which are datetime data types. When the crystal report is run, it prompts the user for the 3 parameters & runs just fine except...</p><p>For the date parameters, it prompts the user to enter a time as well. In previous versions of Crystal, parameters that were datetime data types in the stored procedure were just prompted for the date when the calling crystal report was run.</p><p>I attempted to edit the parameters in the report, but the "Value Type" is grayed out (I assume since the parameter is associated with the stored procedure, rather than being a user defined parameter within the report).  These date parameters are used in a BETWEEN statement in the stored proc, so if the user just enters a date but accepts the default time, the returned data gets flakey due to the addition of the time value passed by the parameter.</p><p> I tried setting a default value for the time, but I have to enter a date along with the time, which the report then uses as the default. The user then has to uncheck the "Pick from defaults" checkbox in order to enter their own date. This is really unwieldly for the end user, especially when they were previously able to just enter a date and not have to be concerned with a time at all.</p><p>Does anyone have suggestions on working around this issue? </p><p>Thanks in advance...</p>

    <p>You mention that you are using CRW version 10 for this.  What&#39;s the data source you are reporting against (you mention a stored procedure - but are you running against Oracle, SQL Server, DB2?).  Are you connecting natively or using ODBC? <br /></p>

Maybe you are looking for

  • I lost my downloaded songs I purchased. Need to download again

    I have lost my recent purchased music downloads while trying to syn two computers. How can I download the songs again? Please help

  • ABAP assistance in getting dates

    Hi Can you help as I am very new to ABAP. In the same query specification, I have some key figures restricted to Basic Start date and others to Actual start date. For the selection screen, the report should be run monthly. I spoke to a collegue and t

  • One space  changes query execution time significantly. Why?

    Hello, my application works on Oracle DB 10.2. Today it started "hanging" on one a select query, which earlier took 1-2 seconds to execute (I waited for several minutes and then stopped it). The query is executed, using the following code: PreparedSt

  • User Exit to add custom field in Component Screen

    Hi Friends, I searched alot but could find exit to add custom field or tab in material component detail screen for SAP 4.7. Please let me know if there is any exit  or workaround possible. Thanks, Raj

  • How to delete all files on hard drive

    I am selling my iMac 27" and I want to deleted all of my files except for the IOS Lion.  Can anyone explain how to do this and get the hard drive back to a factory setting so that I can sell the computer and not have to worry about content being on t