Using VARRAYs as parameters to a Stored Procedure

I'm trying to pass a VARRAY as an IN/OUT parameter into a simple stored procedure by doing the following ..
call.addNamedInOutputArgument(.., .., .., oracle.sql.ARRAY.class);
I'm using a DataReadQuery. I set the call in the query, bind all parameters and add the IN/OUT argument to the query (i.e. query.addArgument(<name>)). Then I create an oracle.sql.ArrayDescriptor to describe the ARRAY.
ArrayDescriptor ad = ArrayDescriptor.createDescriptor(<name of VARRAY>, <connection>);
The VARRAY is of size 1 whose type is INTEGER. I create an ARRAY of Integer objects.
Integer fields[1] = new Integer[1];
fields[0] = new Integer(2);
ARRAY a = new ARRAY(ad, <connection>, fields);
I create a Vector of parameters and add the ARRAY to it. Then I execute the query ..
Object result = session.executeQuery(<query>, <Vector>);
When I execute the query I keep getting an ORA-06550: wrong number or types of arguments in call to <stored procedure>. Any help would be appreciated. Thanks. -Michael-

The workaround above using JDBC directly to call store procedures using VARRAY types is still probably your best solution.
In TopLink 10.1.3 there is a new API on StoredProcedureCall that allows passing the JDBC type code which should allow binding of VARRAY output parameters.
addNamedInOutputArgument(String procedureParameterName, String inArgumentFieldName, String outArgumentFieldName, int type, String typeName) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How to get a list of values used in the WHERE filter of stored procedures and functions in SQL Server

    How can I get a list of values (one or more) used in the WHERE filter of stored procedures and functions in SQL Server?
    How can get a list of values as shown (highlighted) in the sample stored procedure below?
    ALTER PROC [dbo].[sp_LoanInfo_Data_Extract] AS
    SELECT   [LOAN_ACCT].PROD_DT,
                  [LOAN_ACCT].ACCT_NBR, 
                  [LOAN_NOTE2].OFCR_CD, 
                  [LOAN_NOTE1].CURR_PRIN_BAL_AMT, 
                  [LOAN_NOTE2].BR_NBR,
    INTO #Table1
    FROM
                    dbo.[LOAN_NOTE1],
                    dbo.[LOAN_NOTE2],
                    dbo.[LOAN_ACCT]
    WHERE
                    [LOAN_ACCT].PROD_DT = [LOAN_NOTE1].PROD_DT
                    and
                    [LOAN_ACCT].ACCT_NBR = [LOAN_NOTE1].ACCT_NBR
                    and
                    [LOAN_NOTE1].PROD_DT = [LOAN_NOTE2].PROD_DT
                    and
                    [LOAN_NOTE1].MSTR_ACCT_NBR = [LOAN_NOTE2].MSTR_ACCT_NBR
                    and
                    [LOAN_ACCT].PROD_DT = '2015-03-10'
                    and
                    [LOAN_ACCT].ACCT_STAT_CD IN
    ('A','D')
                    and
                    [LOAN_NOTE2].LOAN_STAT_CD IN
    ('J','Z')
    Lenfinkel

    Hi LenFinkel,
    May I know what is purpose of this requirement, as olaf said,you may parse the T-SQL code (or the execution plan), which is not that easy.
    I have noticed that the condition values in your Stored Procedure(SP) are hard coded and among them there is a date values, I believe some day you may have to alter the SP when the date expires. So why not declare 3 parameters of the SP instead hard coding?
    For multiple values paramter you can use a
    table-valued parameter. Then there's no problem getting the values.
    If you could elaborate your purpose, we may help to find better workaround.
    Eric Zhang
    TechNet Community Support

  • StoredProcedureCall with IN OUT Parameters order in Stored Procedure

    Refer to the Toplink documentID:Note 224269.1 - Using IN, OUT and INOUT parameters with StoreProcedureCall. This document can be download from OracleMetaLink:
    http://www.oracle.com/support/metalink/index.html
    I followed the sample code in this document to write a test case for one of complicated PL/SQL codes. The test case showed wrong results for IN/OUT and OUT parameters.
    At the end of the document above, I found this paragraph
    " Check the ordering of the arguments to make sure that they are in the following sequence:
    All 'IN' parameters, All 'OUT' parameters and then all 'INOUT' parameters.
    Your stored procedure must be set up the same way, since this is how values will be passed to it. This is the way in which TopLink stored procedure calls have been designed and implemented. "
    The order of our PL/SQL codes is IN, IN/OUT and OUT. We are not allowed to change our PL/SQL codes because they are currently used in production environment. We do not want to create another versions of PL/SQL codes to comply with IN, OUT, IN/OUT parameter order mentioned above.
    Do you have any work around solution?
    Dennis Nguyen
    LA County Sheriff IT

    I tried a simple example using named parameters and it worked in 9.0.4:
    CREATE OR REPLACE PROCEDURE
    "TEST_904"."STOREDPROCEDURE_INOUT_OUT_IN" (
         P_INOUT IN OUT NUMBER,
         P_OUT OUT NUMBER,
         P_IN NUMBER) AS
    BEGIN
    P_OUT := P_INOUT;
    P_INOUT := P_IN;
    END;
    public void storedProcedureOutInoutInTest() {
         System.out.println("storedProcedureOutInoutInTest");
        StoredProcedureCall call = new StoredProcedureCall();
        call.setProcedureName("STOREDPROCEDURE_INOUT_OUT_IN");
        call.addNamedArgument("P_IN");
        call.addNamedOutputArgument("P_OUT", "P_OUT", Integer.class);
        call.addNamedInOutputArgument("P_INOUT", "P_INOUT", "P_INOUT", Integer.class);
        call.setUsesBinding(true);
        DataReadQuery query = new DataReadQuery();
        query.setCall(call);
        query.addArgument("P_IN");
        query.addArgument("P_INOUT");
        Vector args = new Vector(2);
        args.add(new Integer(1));
        args.add(new Integer(2));
        Object result =  session.executeQuery(query, args);
        Map map = (Map)((Vector)result).firstElement();
        Integer result_p_inout = (Integer)map.get("P_INOUT");
        Integer result_p_out = (Integer)map.get("P_OUT");
         System.out.println("P_INOUT = " +  result_p_inout);
         System.out.println("P_OUT = " +  result_p_out);
    }Result:
    P_INOUT = 1
    P_OUT = 2

  • Using SQL Loader script in a Stored Procedure

    Can I use SQL Loader script in a stored procedure and then execute it from a front-end appl.? The reason for this seemingly convoluted solution is that the users don't want a batch load though the records volume is quite high (around 1 mil). Other loads using ODBC connection or OLE DB seem to be inferior to SQL Loader.

    I would suggest a couple of solutions:
    1. Have a cgi script that can upload the file to the server from a web ui, then have the cgi script call the sql*loader file, and it will insert into the database.
    2. You can try to use External tables. This is avaliable in 9i and onwards. You will be able to make any sql DML on the external table.
    I would normally use sql*loader, move the data to a staging table with nologging, and paralle loading. After it has been loaded into the staging table I would process it into my main tables. Have used this approach with up to 60 million records in one load.
    You can do calls to C procedures, Pro*C procedures through PLSQL, as well as java calls, or use Java stored procedures.
    My experience is that SQL*Loader is the fastest way to load data into the database.

  • HowTo: Using special characters in SQL passthrough stored procedure parameters?

    Hi all,
    I am creating a Visual FoxPro 5.0a application, where I am trying to call a stored procedure in my Oracle database with the following SQLEXEC command (SQLEXEC is the Foxpro function to send sql statements to the ODBC driver):
    lcSQL = "{Call Insert_FRB.NewItemPage('KABO)n$i,30000000000', '184927', '184927', 'MAIR2001011216151314', 'MAIR')}"
    /* Sorry the above command should of course not break accross pages*/
    lnSuccess = sqlexec(1,lcSQL)
    With the parameters given, I get the ODBC error: "Connectivity error: [Oracle][ODBC Oracle Driver]Syntax Error."
    I get the same error, when using the Oracle ODBC 32bit Test utility.
    The call works just fine, if I replace the "$" in the first parameter 'KABO)n$i,30000000000' with a "normal" character, e.g. 'KABO)nAi,30000000000'. Oracle handles the $-character just fine, the stored procedure is working properly when called directly in SQLPLUS8.
    I am using the Oracle ODBC driver sqo32_73.dll Version2.00.03.01.
    Questions:
    How do I have to submit the "$" to the ODBC driver, in order to be passed through to Oracle unchallenged?
    Does anybody know of other special characters, which are not accepted by the ODBC-drivers for Oracle?
    Thanks to any hints,
    Peter

    You could try downloading the Oracle 8.1.7 client and the latest
    Oracle8 ODBC driver, install them on your machine, and verify
    that the failure goes away. That's obviously the acid test.
    I can tell you that when I worked in the ODBC driver group we
    did identify and fix some bugs where our parser wasn't skipping
    string literals. If this particular bug wasn't fixed earlier,
    it almost certainly was then (I'm guessing that work was done 12-
    18 months ago).
    Justin

  • Using Parameterized Arrays in Stored Procedure

    I tried following code to pass array value to stored procedure but its giving error, as I am new to this procedure, please advise what am I missing ?
    Best Regards,
    Luqman
    My code is as below.
    CREATE TYPE num_array AS table of number;
    create or replace procedure give_me_an_array
    ( p_array in num_array )
    as
    begin
    for i in 1 .. p_array.count
    loop
    dbms_output.put_line( p_array(i) );
    end loop;
    end give_me_an_array;
    declare
    mdata num_array;
    begin
    mdata(1) := 1234;
    mdata(2) := 10;
    give_me_an_array(mdata);
    end;

    Hi Satya,
    Now I got it, thanks,
    Can you please advise, if I use the same stored procedure for EMP Table and use my array values to retrieve the selected EMPNo
    I tried following but I could not succeed.
    When I compile the stored procedure, error occurs:
    "inconsistent datatypes: expected NUMBER got NUM_ARRAY"
    for example:
    CREATE TYPE NUM_ARRAY AS TABLE OF NUMBER;
    Create or Replace Package TB_Data
    Is Type CV_Type Is REF CURSOR;
    END TB_DATA;
    Create or Replace Stored Procedure give_me_an_array
    (CV IN OUT TB_DATA.CV_TYPE,
    MEmpNo In Num_Array)
    Is
    Begin
    Open CV for
    Select * from EMP
    Where Empno in MEmpNo;
    End myProc;
    declare
    mdata num_array:=num_array(7839,7844);
    begin
    give_me_an_array(mdata);
    end;
    Best Regards,
    Luqman

  • Passing DATE parameters to Oracle Stored Procedures using ADO

    Does anyone know how can I pass a date parameter to an Oracle
    Stored Procedure? The IN parameter of the procedure is of type
    DATE and the ADO parameter is of type DBDate (I've tried Date
    and DBTimeStamp,too). The execution freezes at "Cmd.Execute".
    Can anyone suggest a solution?
    Thanx for any tips

    As far as I know the documentation on CR & stored procedures says that the REF CURSOR has to be a strongly bound one.
    Could you go into a little more detail? Do you mean I should put a multi-valued parameter into a REF CURSOR? Can you post some code snippets here?

  • Get OUTPUT and RETURN parameters from a stored procedure

    I have a stored procedure (MS SQL Server 2008 R2) like the following example.
    Using Database Connectivity I can get the OUTPUT parameters but I can't get de RECORDSET DATA and de RETURN value.
    Does anybody knows how to do that?
    CREATE PROCEDURE [dbo].[TS_Teste] (@T057_S_NOMEMAQUINA VARCHAR(20), @STATUS INT OUTPUT, @ERRO NVARCHAR(500) OUTPUT)
    AS
    BEGIN     
      DECLARE @TABLE TABLE(CODIGO INT, DESCRICAO VARCHAR(30))
      INSERT INTO @TABLE VALUES (51, 'A')     
      INSERT INTO @TABLE VALUES (52, 'B')
      INSERT INTO @TABLE VALUES (53, 'C')
      SELECT * FROM @TABLE
      SET @STATUS = 1
      SET @ERRO = 'Nenhum erro!'
      RETURN 0
    END
    Solved!
    Go to Solution.
    Attachments:
    SQL SP Return.vi ‏29 KB

    I finaly found what was wrong... It was necessary an only aditional line in the stored procedure. It should be like that:
    CREATE PROCEDURE [dbo].[TS_Teste] (@T057_S_NOMEMAQUINA VARCHAR(20), @STATUS INT OUTPUT, @ERRO NVARCHAR(500) OUTPUT)
    AS
    BEGIN    
      SET NOCOUNT ON;                                                                                               -- NEW LINE!!!
      DECLARE @TABLE TABLE(CODIGO INT, DESCRICAO VARCHAR(30))
      INSERT INTO @TABLE VALUES (51, 'A')    
      INSERT INTO @TABLE VALUES (52, 'B')
      INSERT INTO @TABLE VALUES (53, 'C')
      SELECT * FROM @TABLE
      SET @STATUS = 1
      SET @ERRO = 'Nenhum erro!'
      RETURN 0
    END

  • ERROR WHILE INSERTING BLOBS AS PARAMETERS OF EXISTING STORED PROCEDURE

    I have 2 simple tables to keep large application data (as XMLDOCUMENT in one table and BLOB in another):
    SQL> desc bindata_tbl;
    Name Null? Type
    BDATA_ID NOT NULL NUMBER(10)
    BDATA NOT NULL BLOB
    SQL> desc metadata_tbl;
    Name Null? Type
    MDATA_ID NOT NULL NUMBER(10)
    MDATA NOT NULL SYS.XMLTYPE
    and stored preocedure to input new data into those tables:
    "SP_TEST_BIN_META_DATA"
    i_MetaData in METADATA_TBL.MDATA%TYPE,
    i_BinData in BINDATA_TBL.BDATA%TYPE
    as
    begin
    if i_MetaData is not null then
    insert into METADATA_TBL (MDATA_ID, MDATA)
    values (METADATA_SEQ.nextval, i_MetaData);
    end if;
    if i_BinData is not null then
    insert into BINDATA_TBL (BDATA_ID, BDATA)
    values (BINDATA_SEQ.nextval, i_BinData);
    end if;
    COMMIT;
    -- Handle exceptions
    EXCEPTION
    WHEN OTHERS THEN
    ROLLBACK;
    RAISE;
    end;
    I communicate with database from .Net application using "Oracle.DataAccess 10.1.0.200 (Runtime version v1.0.3705)" component.
    Following procesure is a [simplified] examlple of the code I use, which demonstrates the errors while inserting XMLDOCUMENT and BLOB values simultaneously.
    In my application those should be quite big objects (~200 K XML and ~5-25M binary image data), but following sample keeps failing even with very small-sized objects:
    Line Number
    1          private void PureTest()
    2          {
    3               OracleConnection conn = null;
    4               OracleTransaction tx = null;
    5               OracleCommand command = null;
    6
    7               try
    8               {
    9                    // Open connection
    10                    string strConn = "Data Source=AthenaWf; User ID=AthenaWf; Password=Poseidon";
    11                    conn = new OracleConnection( strConn );
    12                    conn.Open();
    13
    14                    // Begin transaction (not sure if really needed)
    15                    tx = conn.BeginTransaction();
    16
    17                    // Create command
    18                    string strSql = "SP_TEST_BIN_META_DATA";
    19                    command = new OracleCommand();
    20                    command.Connection = conn;
    21                    command.CommandText = strSql;
    22                    command.CommandType = CommandType.StoredProcedure;
    23
    24                    // Create parameters
    25                    // 1) XmlType parameter
    26                    string strXml = "<?xml version=\"1.0\"?><configuration testValue=\"123456789\"/>";
    27                    XmlDocument xmlDoc = new XmlDocument();
    28                    xmlDoc.LoadXml( strXml );
    29                    OracleXmlType oraXml = new OracleXmlType( conn, xmlDoc );
    30                    //oraXml = null;
    31                    //
    32                    OracleParameter xmlPrm = new OracleParameter();
    33                    xmlPrm.ParameterName = "i_MetaData";
    34                    xmlPrm.Direction = ParameterDirection.Input;
    35                    xmlPrm.OracleDbType = OracleDbType.XmlType;
    36                    xmlPrm.Value = oraXml;
    37                    command.Parameters.Add( xmlPrm );
    38
    39                    // 2) Blob type
    40                    byte[] buf = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    41                    OracleBlob oraBlob = new OracleBlob( conn, true );
    42                    //oraBlob.Write( buf, 0, buf.Length );
    43                    oraBlob = null;
    44                    //
    45                    OracleParameter blobPrm = new OracleParameter();
    46                    blobPrm.ParameterName = "i_BinData";
    47                    blobPrm.Direction = ParameterDirection.Input;
    48                    blobPrm.OracleDbType = OracleDbType.Blob;
    49                    blobPrm.Value = oraBlob;
    50                    command.Parameters.Add( blobPrm );
    51
    52
    53                    // Execute command finally
    54                    command.ExecuteNonQuery();
    55                    tx.Commit();
    56               }
    57               catch( Exception ex )
    58               {
    59                    // Clean-up
    60                    if( command != null )
    61                    {
    62                         command.Dispose();
    63                    }
    64                    if( tx != null )
    65                    {
    66                         tx.Dispose();
    67                    }
    68                    if( conn != null )
    69                    {
    70                         conn.Dispose();
    71                    }
    72
    73                    // Display error message
    74                    MessageBox.Show( ex.Message, "Error" );
    75               }
    76          }
    If I try insert only XMLDOCUMENT object (lines 30, 42 are commented out, 43 IS NOT) - everything is OK.
    If I try to insert only BLOB object (lines 30, 42 are NOT COMMENTED OUT, line 43 is commented out) - everything is OK again.
    If I try to insert them both having some values (lines 30, 43 are commented out, 42 is not commented out) - it fails right on "command.ExecuteNonQuery();" (line 54)
    with the following exception:
    "ORA-21500: internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%]".
    Even when I nullify oraBlob before assigning it to OracleParameter value (line 30 is commented out, line 42 and 43 are not) I have the same exception.
    XMLDOCUMENT and DLOB data logically are very coupled objects (in my application), so I really want to insert them simultaneously in one stored procedure in transactional way.
    Is it bug of drivers, server, .net environment, or I miss something in implementation?
    PS. In some articles on Oracle web and in MSDN site I found a mention about necessity of wrapping all write/update operations in a transaction, while working with temporary LOBs. I use it here, but it does not look like changing anything.

    Hello,
    I tested your code with the 10.1.0.4.0 ODP and 10.1.0.4.0 Client and it worked fine.
    Can you please apply the 10.1.0.4.0 patches for both ODP and client to see if this resolves the issue for you.
    Here is the output from the same execution of the ODP application you provided as a testcase. These rows were inserted at the same time when I executed the application and passed the data as parameters to the SP you provided.
    Results of Testing with 10.1.0.4.0
    ==========================
    SQL> select count(*) from BINDATA_TBL
    2 ;
    COUNT(*)
    1
    SQL> select count(*) from METADATA_TBL;
    COUNT(*)
    1
    SQL> select dbms_lob.getlength(bdata) from BINDATA_TBL;
    DBMS_LOB.GETLENGTH(BDATA)
    10
    SQL> select mdata from METADATA_TBL;
    MDATA
    <?xml version="1.0"?><configuration testValue="123456789" />

  • Using an IN Clause in a Stored Procedure

    Hello All:
    I have come to the conclusion that my stored procedure is having a problem with the use of an IN clause using a parameterized query.
    I have in my Stored Procedure the following: AND oh.status_flag IN (p_OrderStatus)
    The p_OrderStatus will contain values along the lines of:
    1). p_OrderStatus = 'X'
    2). p_OrderStatus = 'X', 'S', 'W'
    In my .Net code, I am setting the parameter value as being:
    oCommand.Parameters.Add("p_OrderStatus", OracleDbType.Varchar2).Value = Status;
    However: this isn't working as something in the IN clause doesn't seem to work as I expected, but if I do the same query through a TORA window, it brings back values.
    What is causing this to stop working once I move it to a Stored Procedure and how do I fix it (either the .Net side or the Oracle Side, which I assume it would be something on the Oracle side of things).
    Any help is greatly appreciated
    Thanks
    Andy

    One way I've found to get around this is to have .net pass in a comma seperated list of values into the procedure, then have the procedure split it up into a table and use that in the IN. There's probably a better way to do it, but this works:
    create or replace
    TYPE "STRINGTABLETYPE" AS TABLE OF VARCHAR2(30);
    create or replace
    FUNCTION "FUNC_STR2STRTBL"
    ( p_str in varchar2 ) return
    stringTableType
    as
    l_str long default p_str || ',';
    l_n number;
    l_data stringTableType := stringTabletype();
    begin
    loop
    l_n := instr( l_str, ',' );
    exit when (nvl(l_n,0) = 0);
    l_data.extend;
    l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
    l_str := substr( l_str, l_n+1 );
    end loop;
    return l_data;
    end;
    Then in your actual query procedure, you can do something like this:
    SELECT * FROM table WHERE column IN (select * from THE (select cast(FUNC_STR2TBL(parameter) as STRINGTABLETYPE) from dual))

  • Passing Variable Number of Parameters to Cobol Stored Procedure

    Hi. I have a web front end that needs to access several different tables via Cobol stored procedures. It seems simple enough to call the stored procedures straight away (DAO Pattern perhaps?) but my boss is insistent on having an intermediate Cobol program that decides which table to access. I think he at a bigger picture than I can see.
    The problem lies in the number of parameters that need to be passed to the stored procedures; some need 3, others needs 5, a few need 4. The only two solutions that I can think of are to pass EVERYTHING (we're talking 50 parameters or so) to the intermediate stored procedure and then pulling only what is needed from that data set to access the desired table. Solution number two involves passing everything to a temp table and then pulling what is needed from it. The former solution seems a little cleaner but still involves passing a lot of parameters. If Cobol could handle some sort of dynamic memory allocation (Vector) there seems to be a possible solution there. Though, as far as I know, that isn't possible.
    Any ideas are much appreciated.
    Thanks in advance,
    Chris

    Hi Saurabh,
    The method in which stored procedures are called on form submit is something as follows.
    Let us take your scenario of a form which has multiple checkboxes and a submit button. On clicking the submit button, this form data is submitted using either get or post. The form's submit action invokes a procedure.
    The HTML form code will look something like this..
    htp.formOpen( curl => 'URL /myProcedure',
    cmethod => 'post' );
    htp.formCheckbox( cname => 'myCheckbox'
    cvalue => 'A');
    htp.formCheckbox( cname => 'myCheckbox'
    cvalue => 'B');
    htp.formCheckbox( cname => 'myCheckbox'
    cvalue => 'C');
    htp.formSubmit( cname => 'myButton',
    cvalue => 'OK');
    Now, whenever the submit button is clicked, all these form values are passed to our stored procedure 'myProcedure'.
    "myProcedure" looks something like this.
    procedure myProcedure
    myCheckbox IN sys.owa_util.vc_arr,
    myButton IN VARCHAR2
    is
    begin
    end myProcedure;
    The point to be noted here is that the name of the variable being passed in the procedure is the same as the name of the HTML element being created in the HTML form. So, there is a direct mapping between the elements in the HTML form and the procedure parameters.
    Another noteworthy point is that since you have multiple checkboxes in your HTML form, it is impractical to name all the checkboxes differently and then pass those many parameters to your procedure (Imagine a scenario where there are a hundred check-boxes in an HTML form!). So portal allows you to give the same name (cname) to all the checkboxes in your HTML form, and if multiple checkboxes are checked, it will return all the checkbox values in an array (Note the usage of "myCheckbox IN sys.owa_util.vc_arr" in myProcedure).
    You can check out this link for more information.
    Re: retrieving data from fields
    Thanks,
    Ashish.

  • Picking up Parameters in a Stored Procedure

    Hi,
    Using the following sqlplus call I am executing a sql script.
    sqlplus username/password @test.sql "TEST1" "TEST2"
    The test.sql script makes the following call:
    execute TABLEOWNER.TEST_SP;
    Can anyone tell me how to pass parameters shown in the sqlplus call to the execute command so that they are available to the stored procedure?
    And then how do I pick those two parameter values up in the stored procedure?
    I have a procedure created using the following syntax, but when I try to create the procedure using this syntax I get prompted for a value for 1, and then for 2, the procedure then creates without any errors but when I check the definition for the procedure I can see that rather then the &1 and &2 parameters, they have been replaced with whatever I enter for 1 and 2 when the procedure was created.
    CREATE OR REPLACE PROCEDURE TEST_SP AS
    --Declare and initialise variable passed from shell script
    lvBATCH_ID VARCHAR2(10) := '&1';
    lvCREATED_DATE VARCHAR2(6) := '&2';
    Thanks.

    The procedure will just be passed parameters as normal. It doesn't care what calls it:
    CREATE OR REPLACE PROCEDURE test_sp
        ( p1 VARCHAR2, p2 VARCHAR2 )
    AS
    BEGIN
        DBMS_OUTPUT.PUT_LINE(p2 || ', ' || p1);
    END test_sp;Your SQL*Plus script would contain something like:
    exec test_sp('&1','&2')(the single quotes being required for character literals in this example - you wouldn't need them for numeric values)
    You would call the SQL*Plus script as
    @test_script World Hello

  • Varbinary(max) parameters in Nested Stored Procedures by value or reference _Expand / Collapse

    Consider a situation where a stored procedure taking a varbinary(max) (BLOB) input parameter
    then calls a nested stored procedure and passes along that varbinary(max) as an input parameter to the nested stored procedure.
    Is a copy of the BLOB provided to the nested stored procedure (passed by value) OR is the BLOB passed by reference.
    My interest is in understanding the potential memory hit when handling large BLOBs in this environment.
    For example, if the BLOB is 200MB, will SQL server need to allocate memory for a new copy each time it's passed to another stored procedure at the next nestlevel?
    Looks like table type parameters are passed by reference, but I haven't been able to find any info on BLOBS in this context.

    The semantics for parameters in SQL Server is copy-in/copy-out. However, this does not mean that there cannot be optimizations. That is, there is no need to copy the BLOB, as long as the procedure does not change it. Whether they actually have such an optimization,
    I don't know.
    I composed the repro below, and it is sort of interesting. If I restart my instance (SQL 2014), the memory usage grows with about 40 M for each nesting call, which certainly indicates that the BLOB is copied over and over again. But if I then run it again,
    the growth is not the same. This may be because, it uses buffers already available. (A BLOB has to be a handle like a table when it is over some size.) Then again, it means that it is squeezing something else out of the cache.
    CREATE PROCEDURE K  @h varchar(MAX) AS
       SELECT SUM(pages_kb)*8192 AS K, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       SELECT @h = ''
    go
    CREATE PROCEDURE L  @h varchar(MAX) AS
       SELECT SUM(pages_kb)*8192 AS L1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       EXEC K @h
       SELECT SUM(pages_kb)*8192 AS L2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       --SELECT @h = ''
    go
    CREATE PROCEDURE M  @h varchar(MAX) AS
       SELECT SUM(pages_kb)*8192 AS M1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       EXEC L @h
       SELECT SUM(pages_kb)*8192 AS M2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       --SELECT @h = ''
    go
    CREATE PROCEDURE N  @h varchar(MAX) AS
       SELECT SUM(pages_kb)*8192 AS N1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       EXEC M @h
       SELECT SUM(pages_kb)*8192 AS N2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
       --SELECT @h = ''
    go
    DECLARE @h varchar(MAX) = replicate(cast('ABCD' AS varchar(MAX)), 1E7)
    EXEC N @h
    go
    DROP PROCEDURE K, L, M, N
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Maximum number of parameters sent to stored procedure

    I have a web form from where I insert data to Oracle. There are at least 20 fileds on the form. For INSERT I want to use Stored Procedure. But in this case for VALUES section of the INSERT statement I need to send that many- in this case 20 parameters. Is this normal for a procedure to receive 20 parameters? If it's not, then what way should I follow to perform this? I know technically there's no problem but is this normal programming or database managementwise? I think this is the basic thing all web developer do all the time.

    He's got 20 fields on a web form and you think using SQL*Loader is a good idea ?because I do not believe that he has to enter these fields once time.
    You want him to write the values to a flat file, generate a control file, then invoke SQL*Loader ?I know that the first time you create all those files can be a problem, but when you have all , the next times its just change the information into flat file.
    Did you read the question ?Yes, i did
    It's only my opinion, He can accept it or not.
    any other question not related to help him to solve his problem?

  • How I ca have the name of parameters of  an stored procedure?

    Hi,
    I have an stored procedure with a lot of parameters. I want to list them automatically by writing codes to show me the name of all parameters
    thanks,
    mandana

    Back to your original question... it's a bit hard to answer this without you saying what DB system you're using, as the answer will be different depending on the system.
    Actually one can do it with JDBC easily enough, so the solution would be DB-independent.
    Have a look at this: http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html, specifically http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getProcedures(java.la ng.String,%20java.lang.String,%20java.lang.String) and http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getProcedureColumns(j ava.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String).
    I did have some proof-of-concept code for this at some stage, but I cannae find it now, sorry.
    Adam

Maybe you are looking for

  • Asset Issue ?

    Hi I have a problem which says likes this at the time of a Down payment request creation: Message no. F5378 The asset number assigned in the purchase document  is different from the asset number entered manually cannot be transferred, because the 'As

  • Ringtones and text tones not working

    I finally figured out on my own that I have to turn OFF Do Not Disturb for my Iphone 4 to alert me to calls or texts. I had it set for DNDisturb 10p-9a. It's 6:55p. I got sick of missing calls and texts. Why is DND messed up? This has been happening

  • BeginTimer and EndTimer Not Working In Data-Driven Unit Test Using DataSource Attribute

    Using VS2012 Ultimate I have a unit test with the <DataSource> attribute which passes in values from a CSV file.  I'm wrapping the unit test in a load test.  I expect a Transaction to appear in the load test results for each row in my DataSource due

  • Getting dynamic lookup error!

    I am using OSX 10.9.5 and getting the below error: dyld: lazy symbol binding failed: Symbol not found: _OCIEnvCreate   Referenced from: /Users/Desktop/socket.io/node_modules/node-oracledb/build/Release/oracledb.node   Expected in: dynamic lookup dyld

  • How do I create folders in my bookmarks?

    I have a bunch of recipes in my bookmark menu. I want to consolidate them into one folder in the menu but can't find how to do set up a new, empty folder.