How to call a procedure with SYS_REFCURSOR OUT parameter

Hi,
Using Oracle 11g R2.
I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
create or replace procedure testprocedure (result OUT sys_refcursor)
as
begin
   open result for
      select 1 from dual
      union all
      select 2 from dual;
end;
I'd like to call this procedure similar to the way a query is called and executed. Like this
select * from testprocedure
I've seen plenty of examples on the web which show how it is possible to loop through results of a sys_refcursor inside of an anonymous block and display the results using dbms_output.putline, but this isn't the method I am looking for.

I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
No - you can only use schema object types (SQL) in SQL queries and only then if you call a function.
The function can return a SQL collection type or it can be a PIPELINED function whose return value is a SQL collection type. Either way your query will use the TABLE function and be of the form:
select * from TABLE(testfunction);
This is sample code for a PIPELINED function based on the SCOTT.EMP table. The function takes a department number parameter and returns the EMP rows for that department:
-- type to match emp record
create or replace type emp_scalar_type as object
  (EMPNO NUMBER(4) ,
   ENAME VARCHAR2(10),
   JOB VARCHAR2(9),
   MGR NUMBER(4),
   HIREDATE DATE,
   SAL NUMBER(7, 2),
   COMM NUMBER(7, 2),
   DEPTNO NUMBER(2)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
-- pipelined function
create or replace function get_emp( p_deptno in number )
  return emp_table_type
  PIPELINED
  as
   TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
    emp_cv EmpCurTyp;
    l_rec  emp%rowtype;
  begin
    open emp_cv for select * from emp where deptno = p_deptno;
    loop
      fetch emp_cv into l_rec;
      exit when (emp_cv%notfound);
      pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
          l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
    end loop;
    return;
  end;
select * from table(get_emp(20))

Similar Messages

  • How to call a procedure which returns out parameter in form personalization

    Dear All,
    I have one procedure which is having 2 parameter in and one parameter out .
    The question is how to get the parameter out in from personalization in a local or global variable?
    Thanks

    Yes.
    You can use the "forms_ddl" builtin
    See the following examples. Make sure you include the single quotes as well as the = sign in the begining.
    See http://phenix.blog.163.com/blog/static/8397219320096213953151/
    http://oracle.anilpassi.com/forms-personalizations.html
    Sandeep Gandhi

  • How can I Create function with an  out Parameter

    how all
    how can I Create function with an out Parameter
    I try to create it it sucess but how can I CALL it , it give me error
    please I want A simple example
    thanks

    3rd post on same question by same user :
    Re: how can I Create function with an  out Parameter
    how can I Create function with an  out Parameter

  • How to call stored procedure with multiple parameters in an HTML expression

    Hi, Guys:
    Can you show me an example to call stored procedure with multiple parameters in an HTML expression? I need to rewrite a procedure to display multiple pictures of one person stored in database by clicking button.
    The orginal HTML expression is :
    <img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">which calls a procedure as:
    procedure dl_sor_image (p_offender_id IN NUMBER)now I rewrite it as:
    PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number)could anyone tell me the format for the html expression to pass multiple parameters?
    Thanks a lot.
    Sam

    Hi:
    Thanks for your help! Your question is what I am trying hard now. Current procedure can only display one picture per person, however, I am supposed to write a new procedure which displays multiple pictures for one person. When user click a button on report, APEX should call this procedure and returns next picture of the same person. The table is SOR_image. However, I rewrite the HTML expression as follows to test to display the second image.
    <img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75"> The procedure code is complied OK as follows:
    create or replace
    PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
        v_mime_type VARCHAR2(48);
        v_length NUMBER;
        v_name VARCHAR2(2000);
        v_image BLOB;
        v_counter number:=0;
        cursor cur_All_Images_of_Offender is
          SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
          FROM sor_image
          WHERE offender_id = p_n_Offender_id;
        rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
    BEGIN
        open cur_All_Images_of_Offender;
        loop
          fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
          v_counter:=v_counter+1;
          if (v_counter=p_n_image_Count) then
            owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
            htp.p('Content-length: '||rec_Image_of_Offender.image_length);
            owa_util.http_header_close;
            wpg_docload.download_file (rec_Image_of_Offender.image);
          end if;
          exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
        end loop;
        close cur_All_Images_of_Offender;
    END Sor_Display_Current_Image; The procedure just open a cursor to fetch the images belong to the same person, and use wpg_docload.download_file function to display the image specified. But it never works. It is strange because even I use exactly same code as before but change procedure name, Oracle APEX cannot display an image. Is this due to anything such as make file configuration in APEX?
    Thanks
    Sam

  • Db Adapter: problems by calling a procedure with type as parameter

    Hi,
    We using a db adapter in a bpel process.
    In that dapter we call a procedure with types as in and out parameter
    package.procedure(p_in IN in_t, p_rsult OUT result_t).
    When we calling the procedure, we don't call the procedure directly.
    We call that procedure in a schema who have the execute rigths for the package and the types.
    When we run the process we get the error message
    unable to convert the xsd element p_in whose user defined type is in_t
    cause: java.sql.SQLException: ora-01436 connect by loop in user data
    I am not shore if I draw the right conclusions.
    Is it rigth that bpel have a problem by using types as parameter when using two schematas? Isn't it a bug.
    For every help I was thankful.
    Thanks in advanced.
    Michael

    Hi,
    thanks for the hint. I have implemented a wrapper package and it's working well.
    Only one crux. The parameter of the called procedure are data types and not simple types.
    CREATE OR REPLACE TYPE pesa_db_return_t AS OBJECT
    (SUCCESS_MSG varchar2(255)
    ,FAULT_SQLCODE varchar2(255)
    ,FAULT_SQLMSG varchar2(255)
    Wrapper package...
    IS
    PROCEDURE prc_writeReOinDB (p_AuftragRechnungOnline IN pesa_data.pesa_tivu_reo_t
    ,p_result OUT pesa_data.pesa_db_return_t)
    IS
    BEGIN
    pkg_pesa_reo.prc_writeReOinDB (p_AuftragRechnungOnline => p_AuftragRechnungOnline
    ,p_result => p_result
    END prc_writeReOinDB;
    END pkg_pesa_wrapper;
    So I have to declare the parameter with the schema user in front of.
    Now, we have deployed thes sources on a second enviroment and get following error:
    <2008-04-22 15:01:25,749> <ERROR> <eweber.collaxa.cube.engine.dispatch> <BaseScheduledWorker::process> Failed to handle dispatch message ... exception ORABPEL-05002
    Message handle error.
    An exception occurred while attempting to process the message "com.collaxa.cube.engine.dispatch.message.instance.CallbackDeliveryMessage"; the exception is: Type class not found.
    Cannot find class for type "org.apache.xerces.dom.ElementNSImpl". Please check that the class is located in the classpath.
    You have a hint for me what I have to do?
    Thanks in advanced,
    Michael

  • How to change stored procedure with Table Valued Parameter

    I am not sure how to change the normal stored procedure with Table Value Parameter.Do I have to create a separate Table or do I have to create a datatype. Can you please help me with this
    ALTER PROCEDURE [dbo].[uspInsertorUpdateINF]
    @dp_id char(32),
    @dv_id char(32),
    @em_number char(12),
    @email varchar(50),
    @emergency_relation char(32),
    @option1 char(16),
    @status char(20),
    @em_id char(35),
    @em_title varchar(64),
    @date_hired datetime
    AS
    BEGIN
    SET NOCOUNT ON;
    MERGE [dbo].[em] AS [Targ]
    USING (VALUES (@dp_id, @dv_id , @em_number, @email, @emergency_relation, @option1, @status, @em_id, @em_title, @date_hired))
    AS [Sourc] (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired)
    ON [Targ].em_id = [Sourc].em_id
    WHEN MATCHED THEN
    UPDATE
    SET dp_id = [Sourc].dp_id,
    dv_id = [Sourc].dv_id,
    em_number = [Sourc].em_number,
    email = [Sourc].email,
    emergency_relation = [Sourc].emergency_relation,
    option1 = [Sourc].option1,
    status = [Sourc].status,
    em_title = [Sourc].em_title,
    date_hired = [Sourc].date_hired
    WHEN NOT MATCHED BY TARGET THEN
    INSERT (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title,date_hired)
    VALUES ([Sourc].dp_id, [Sourc].dv_id, [Sourc].em_number, [Sourc].email, [Sourc].emergency_relation, [Sourc].option1, [Sourc].status, [Sourc].em_id, [Sourc].em_title, [Sourc].date_hired);
    END;

    It's not clear how you would change the procedure. But assuming that you want to replace the existing scalar parameters with tabular input, this is how you would do it. You first create a table type:
    CREATE TYPE  Insertor_type AS TABLE
        (dp_id                char(32),
         dv_id                char(32),
        em_number            char(12),
        email                varchar(50),
        emergency_relation   char(32),
        option1              char(16),
        status               char(20),
        em_id                char(35),
        em_title             varchar(64),
        date_hired           datetime)
    Then you change the procedure header:
    ALTER PROCEDURE [dbo].[uspInsertorUpdateINF] @tvp Insertor_type READONLY AS
    And finally you change the USING clause:
       USING (SELECT dp_id, dv_id , em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired
              FROM   @tvp) AS [Sourc] ON [Targ].em_id = [Sourc].em_id
    The rest is fine as it is.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to call a oracle procedure with in/out parameter frm unix shell script?

    Hi,
    I need to call an oracle stored procedure from unix script. The procedure has 1 input parameter and 2 output parameter. Please send me the syntax for the same. Based on the output values of procedure, I have to execute some more commands in unix script.
    Thanks and regards
    A

    An example :
    TEST@db102 SQL> select ename, job from emp
      2  where empno = 7902;
    ENAME      JOB
    FORD       ANALYST
    TEST@db102 SQL> create or replace procedure show_emp (
      2     v_empno in      number,
      3     v_ename out     varchar2,
      4     v_job   out     varchar2 )
      5  is
      6  begin
      7     select ename, job into v_ename, v_job
      8     from emp
      9     where empno = v_empno;
    10  end;
    TEST@db102 SQL> /
    Procedure created.
    TEST@db102 SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [ora102 work db102]$ IN=7902
    [ora102 work db102]$ set `sqlplus -s test/test@db102 << !
    var out1 varchar2(30);
    var out2 varchar2(30);
    set pages 0
    set feed off
    exec show_emp($IN,:out1,:out2);
    print
    exit
    `[ora102 work db102]$ echo $1 $2
    FORD ANALYST
    [ora102 work db102]$                           

  • Calling Oracle procedure with two OUT parameters

    Hi I am having an Oracle procedure which return ref cursor. I also want to result one more out parameter result. How Can I call the procedure in SQL. Below is the way I am calling my stored procedure with one parameter.
    proc_Test (p_resultset=> My_cursor)
    How can I call the procedure when I have one more OUT parameter. Second parameter returns 0 or 1.
    Thanks in adv

    Yes its possible to use multiple parameter as OUT type in procedure.
    SQL>set serveroutput on size 1000000;
    SQL>CREATE OR REPLACE PROCEDURE myproc(p_cv OUT SYS_REFCURSOR, p_num OUT NUMBER) AS
      2  BEGIN
      3    OPEN p_cv FOR SELECT 'Hello Oracle' sayhello FROM DUAL ;
      4    p_num := 1;
      5  END;
      6  /
    Procedure created.
    SQL>VAR cv REFCURSOR;
    SQL>VAR num NUMBER;
    SQL>EXEC myproc(:cv, :num);
    PL/SQL procedure successfully completed.
    SQL>PRINT cv;
    SAYHELLO
    Hello Oracle
    SQL>PRINT num;
           NUM
             1
    SQL>
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to call a procedure with two arguments

    Hi,
    I have a procedure with two arguments, ie. myprocedure(p1 in number,p2 in number) to display a blob image.
    how can I call out this blob image in url.
    I tried http://127.0.0.1:7777/pls/apex/SCHEMA.myprocedure?p1=1&p2=2 , but it don't work..
    Thanks
    vincent

    Vincent,
    As long as you have been granted the ability to execute the procedure and there are no spaces in the url and you have not misspelled the parameter names then this looks right.
    Here is a link to a procedure to download a file which takes two parameters.
    http://mywebsite.com/pls/htmldev/schema.package.function.download_file?p_session_id=1221970786026206&p_seq_id=724
    Cheers,
    Tyson Jouglet

  • Viewobject - Stored Procedure with sys_refcursor out

    Hi,
    I have been trying to call an Oracle stored procedure which returns sys_refcursor as an out parameter.
    Even though I register out parameter in callStoreFunction method, I am getting "PLS-00306: wrong number or types of arguments in call".
    You can find piece of codes below.
    Could you please help?
    Thanks in advance.
    Stored Procedure;*
    CREATE OR REPLACE PROCEDURE SP_GET_PRODUCT_DETAIL_BY_ID(
    ID_in IN NUMBER,
    p_product_refcur OUT SYS_REFCURSOR
    IS
    BEGIN
    OPEN p_product_refcur FOR SELECT * FROM PRODUCT_DETAIL WHERE ID = ID_in;
    END SP_GET_PRODUCT_DETAIL_BY_ID;
    Java Code*
    The code that calls function method;
    ResultSet rs = (ResultSet)callStoredFunction(OracleTypes.CURSOR,"SP_GET_PRODUCT_DETAIL_BY_ID(?)",new Object[]{new Number(3)});
    Call function method;
    protected Object callStoredFunction(int sqlReturnType, String stmt, Object[] bindVars) {
    CallableStatement st = null;
    try {
    System.out.println("222222");
    // 1. Create a JDBC CallabledStatement
    st = getDBTransaction().createCallableStatement("begin ? := " + stmt + ";end;", 0);
    // 2. Register the first bind variable for the return value
    st.registerOutParameter(1, sqlReturnType);
    if (bindVars != null) {
    // 3. Loop over values for the bind variables passed in, if any
    for (int z = 0; z < bindVars.length; z++) {
    // 4. Set the value of user-supplied bind vars in the stmt
    st.setObject(z+2, bindVars[z]);
    // 5. Set the value of user-supplied bind vars in the stmt
    st.executeUpdate();
    // 6. Return the value of the first bind variable
    return st.getObject(1);
    } catch (SQLException e) {
    e.printStackTrace();
    throw new JboException(e);
    } finally {
    if (st != null) {
    try {
    // 7. Close the statement
    st.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }

    Hi mate,
    Sorry about that. My Jdev version is 11.1.2.3.0.
    The use case is that I am trying to call a SP from a VO which is triggered from App Module. I have a bind parameter in App Module for SP input, but at the moment I am using a static value for test purpose.
    I am able to make a call from App Module to SP via VO but got an error as I am calling with wrong parameters.
    Stored Procedure;_
    CREATE OR REPLACE PROCEDURE SP_GET_PRODUCT_DETAIL_BY_ID(
       ID_in IN NUMBER,
       p_product_refcur OUT SYS_REFCURSOR
    IS
    BEGIN
       OPEN p_product_refcur FOR SELECT * FROM PRODUCT_DETAIL WHERE ID = ID_in;
    END SP_GET_PRODUCT_DETAIL_BY_ID;
    Java Code_
    The code that calls function method;
    ResultSet rs = (ResultSet)callStoredFunction(OracleTypes.CURSOR,"SP_GET_PRODUCT_DETAIL_BY_ID(?)",new Object[]{new Number(3)});
    Call function method;
    protected Object callStoredFunction(int sqlReturnType, String stmt, Object[] bindVars) {
       CallableStatement st = null;
       try {
          // 1. Create a JDBC CallabledStatement
          st = getDBTransaction().createCallableStatement("begin ? := " + stmt + ";end;", 0);
          // 2. Register the first bind variable for the return value
          st.registerOutParameter(1, sqlReturnType);
          if (bindVars != null) {
             // 3. Loop over values for the bind variables passed in, if any
             for (int z = 0; z < bindVars.length; z++) {
                // 4. Set the value of user-supplied bind vars in the stmt
                st.setObject(z+2, bindVars[z]);
          // 5. Set the value of user-supplied bind vars in the stmt
          st.executeUpdate();
          // 6. Return the value of the first bind variable
          return st.getObject(1);
          } catch (SQLException e) {
             e.printStackTrace();
             throw new JboException(e);
          } finally {
             if (st != null) {
                try {
                   // 7. Close the statement
                   st.close();
                } catch (SQLException e) {
                   e.printStackTrace();
    The exact error;
    java.sql.SQLException: ORA-06550: line 1, column 14:
    PLS-00306: wrong number or types of arguments in call to 'SP_GET_PRODUCT_DETAIL_BY_ID'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignoredThanks alot.

  • How to call a procedure with refcursor  from another  plsql unit

    example I created a pkg with the a procedure that returns a REFCURSOR.
    Now I need to call this procedure from another pkg and use the refcursor values in other pkg.
    Help please.......
    PROCEDURE CustomerSite_Get (p_Registry IN VARCHAR2,
    p_CustomerNumber IN VARCHAR2, p_Cursor IN OUT t_cursor);
    PROCEDURE CustomerSite_Get (p_Registry IN VARCHAR2,
    p_CustomerNumber IN VARCHAR2, p_Cursor IN OUT t_cursor)
    IS
    -- 0903: Include BillToName
    BEGIN
    OPEN p_Cursor FOR
         SELECT S.LOCATION CustomerSite, S.SITE_USE_ID CustomerSiteID, C.CUSTOMER_NAME BillToName
         FROM RA_CUSTOMERS C,
    RA_ADDRESSES A,
    RA_SITE_USES S,
    UWA_REGISTRY R,
    UWA_REGISTRY_BILL_TO B
         WHERE C.CUSTOMER_ID = A.CUSTOMER_ID
         AND A.ADDRESS_ID = S.ADDRESS_ID
         AND S.SITE_USE_ID = B.SITE_USE_ID
         AND R.REGISTRY_ID = B.REGISTRY_ID
         AND B.TRIP_BILLING != 'N'
         AND R.DELETE_FLAG != 'Y'
              AND R.Registry = p_Registry
              AND R.CUSTOMER_NUM = p_CustomerNumber
         ORDER BY S.LOCATION;
    END CustomerSite_Get;
    thanks,
    Anitha.
    Edited by: user521218 on May 6, 2009 1:24 PM

    Hi Anitha,
    try this,
    -- PKG_A
    Procedure CustomerSite_Get( p_Registry       IN Varchar2
                              , p_CustomerNumber IN Varchar2
                              , p_Cursor         IN OUT t_cursor) Is
    Begin
       PKG_B.CustomerSite_Get( p_Registry     
                             , p_CustomerNumber
                             , p_Cursor );
    End;
    -- PKG_B
    Procedure CustomerSite_Get(p_Registry       IN Varchar2
                              ,p_CustomerNumber IN Varchar2
                              ,p_Cursor         IN OUT t_cursor) Is
    Begin
       Open p_Cursor For
          SELECT S.LOCATION      CustomerSite
                ,S.SITE_USE_ID   CustomerSiteID
                ,C.CUSTOMER_NAME BillToName
            FROM RA_CUSTOMERS         C
                ,RA_ADDRESSES         A
                ,RA_SITE_USES         S
                ,UWA_REGISTRY         R
                ,UWA_REGISTRY_BILL_TO B
           WHERE C.CUSTOMER_ID = A.CUSTOMER_ID
             AND A.ADDRESS_ID = S.ADDRESS_ID
             AND S.SITE_USE_ID = B.SITE_USE_ID
             AND R.REGISTRY_ID = B.REGISTRY_ID
             AND B.TRIP_BILLING != 'N'
             AND R.DELETE_FLAG != 'Y'
             AND R.Registry = p_Registry
             AND R.CUSTOMER_NUM = p_CustomerNumber
           Order BY S.LOCATION;
    End CustomerSite_Get;regards,
    Christian Balz

  • Errer when, Call from java to pl sql procedure with table out parameter

    Hi ,
    Please help me ? It's urgent for me .....
    My Oracle Code is like this ,
    CREATE TABLE TEST_TABLE ( DATE1 DATE, VALUE_EXAMPLE VARCHAR2(20 BYTE), VALUE2_EXAMPLE VARCHAR2(20 BYTE), VALUE3_EXAMPLE NUMBER ); CREATE OR REPLACE TYPE TONERECORDTEST AS OBJECT ( DATE1 DATE, VALUE_EXAMPLE VARCHAR2(20), VALUE2_EXAMPLE VARCHAR2(20), VALUE3_EXAMPLE NUMBER ); CREATE OR REPLACE TYPE TTESTTABLE IS TABLE OF TONERECORDTEST; CREATE OR REPLACE PACKAGE test_collection_procedures AS PROCEDURE testCallProcedureFromJava(start_time IN DATE, end_time IN DATE, table_data OUT TTesttable); END test_collection_procedures; / CREATE OR REPLACE PACKAGE BODY test_collection_procedures AS PROCEDURE testCallProcedureFromJava(start_time IN DATE, end_time IN DATE, table_data OUT TTesttable) IS BEGIN SELECT TONERECORDTEST(date1, value_example, value2_example, value3_example) BULK COLLECT INTO table_data FROM TEST_TABLE WHERE DATE1>=start_time AND DATE1<=end_time; END testCallProcedureFromJava; END test_collection_procedures;
    And my Java Code is like
    import java.sql.Connection; import java.sql.DriverManager; import oracle.jdbc.OracleCallableStatement; import oracle.jdbc.OracleTypes; import oracle.sql.ARRAY; import oracle.sql.ArrayDescriptor; import oracle.sql.STRUCT; import oracle.sql.StructDescriptor; public class testPLCollectionType { public static void main(java.lang.String[] args) { try{ //Load the driver Class.forName ("oracle.jdbc.driver.OracleDriver"); // Connect to the database Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@serverbd:1521:squema1","user", "password"); // First, declare the Object arrays that will store the data (for TONERECORDTEST OBJECT TYPE) Object [] p2recobj; Object [] p3recobj; Object [] p4recobj; // Declare the Object Arrays to hold the STRUCTS (for TTESTTABLE TYPE) Object [] p2arrobj; // Declare two descriptors, one for the ARRAY TYPE // and one for the OBJECT TYPE. StructDescriptor desc1=StructDescriptor.createDescriptor("TONERECORDTEST",conn); ArrayDescriptor desc2=ArrayDescriptor.createDescriptor("TTESTTABLE",conn); // Set up the ARRAY object. ARRAY p2arr; // Declare the callable statement. // This must be of type OracleCallableStatement. OracleCallableStatement ocs = (OracleCallableStatement)conn.prepareCall("{call test_collection_procedures.testCallProcedureFromJa va(?,?,?)}"); // Declare IN parameters. Realize that are 2 DATE TYPE!!! Maybe your could change with setDATE ocs.setString(1,"01-JAN-04"); ocs.setString(2,"10-JAN-05"); // Register OUT parameter ocs.registerOutParameter(3,OracleTypes.ARRAY,"TTESTTABLE"); // Execute the procedure ocs.execute(); // Associate the returned arrays with the ARRAY objects. p2arr = ocs.getARRAY(3); // Get the data back into the data arrays. //p1arrobj = (Object [])p1arr.getArray(); p2arrobj = (Object [])p2arr.getArray(); System.out.println("Number of rows="+p2arrobj.length); System.out.println("Printing results..."); for (int i=0; i<p2arrobj.length; i++){ Object [] piarrobj = ((STRUCT)p2arrobj).getAttributes();
    System.out.println();
    System.out.print("Row "+i);
    for (int j=0; j<4; j++){
    System.out.print("|"+piarrobj[j]);
    }catch (Exception ex){
    System.out.println("Exception-->"+ex.getMessage());
    Actually when i running the java program it is showing error
    Exception-->ORA-06550: line 1, column 58:
    PLS-00103: Encountered the symbol "VA" when expecting one of the following:
    := . ( @ % ;
    The symbol ":=" was substituted for "VA" to continue.
      I am not getting the error .Please help me out Dhabas Edited by: Dhabas on Jan 12, 2009 3:49 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    // Declare the callable statement.
    // This must be of type OracleCallableStatement.
    ..."{call test_collection_procedures.testCallProcedureFromJa va(?,?,?)}");Looks like Ja divorced va.

  • Calling a Procedure with IN & OUT Parameters

    Hello,
    I usually call my procedures using the following way
    declare variable error_msg varchar2(50)
    exec simple_msg('ABC,'ABC','ABC',:error_msg);
    CREATE OR REPLACE PROCEDURE SIMPLE_MSG (
    ID IN VARCHAR2,
    URL IN VARCHAR2,
    LIST IN VARCHAR2,
    ERROR_MSG OUT VARCHAR2
    Now my question is i am trying to call a proc which has IN OUT parameters. Can somebody guide me on how to call the proc. Thanks
    CREATE OR REPLACE PROCEDURE SIMPLE_MSG (
    ID IN VARCHAR2,
    URL IN VARCHAR2,
    LIST IN VARCHAR2,
    NAME IN OUT VARCHAR,
    ERROR_MSG OUT VARCHAR2

    Hi,
    IN OUT parameters are passed just like OUT paramenters: you must pass a variable.
    If you need to set the IN OUT parameter before calling the procedure, then either
    (a) use a separate EXEC command:
    EXEC  :name := 'Original name';
    EXEC  simple_msg ('ABC', 'ABC', 'ABC', :name, :error_msg);or
    (b) use an anonymous PL/SQL block, like this:
    BEGIN
        :name := 'Original name';
        simple_msg ('ABC', 'ABC', 'ABC', :name, :error_msg);
    END;
    /The parameter can be either a bind variable (as shown above), or a local variable (that can be used only in the block).

  • How to call sql procedure with parameter from java

    Hello,
    i am trying to call one sql procedure with two parameters from java.
    the first parameter is In parameter, the second is OUT.
    the return value of this java method should be this second parameter value.
    the following is my java code:
    protected String getNextRunNumber() {
         String runnumber=null;
         String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
    CallableStatement state = null;
    try{
         Connection con= getDatabaseConnection();
         state = con.prepareCall(sql);
         state.setString(1, m_appKeyExport);
         state.registerOutParameter(2,Types.NUMERIC,0);
         state.execute();
    ResultSet resultR = (ResultSet)state.getObject(2);
         while (resultR.next()) {
              runnumber=resultR.getBigDecimal(1).toString();
    catch (SQLException e){System.out.println("You can not get the export next run number properly");}
    return runnumber;
    i got error message like:
    java.lang.ClassCastException: java.math.BigDecimal
    As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.
    Please help me to solve this problem.
    Thanks a lot.

    state.execute();
    i try to use debug to find the problem, in this line, i saw
    OracleCallableStatement(OraclePreparedStatement).execute() line: 642 [local variables unavailable]
    is this the problem?

  • How to execute a stored procedure with an out parameter ?

    Guys I am struggling with executing a stored procedure from sql plus.I mean my stored procedure has 2 input parameter and 1 out put parameter (status of the execution).
    MY_PROCEDURE(p_name in varchar2,p_age in number,p_status out varchar2)
    end my_procedure;
    When I say
    EXECUTE MY_PROCEDURE('manohar','Shetty');
    i get insufficient parameters errors.
    please help.

    EXECUTE isn't a valid PL/SQL construct. It's a SQL*Plus command. You don't want to put any SQL*Plus commands in a PL/SQL block.
    You can always execute a stored procedure purely through PL/SQL
    begin
      my_stored_procedure( x, y, z );
    end;SQL*Plus happens to give you the execute command so you can avoid the begin and end statements.
    Justin

Maybe you are looking for

  • Append error message to itab and download to excel

    Hi GURUS, Need urgent help I have an internal table  ( say columns a,b,c) I need to validate the fields and upload to ztable. If any of the row fails during validation. I need to write a corresponding message and append it to the contents of itab--ou

  • XI 3.1 SR3 - Oracle Database 10202 64-bit

    Dear Friends, We are in the process of installing the XI 3.1 SR3 (32-bit) on the REDHAT Linux x86-64 bit OS server. On this server, we have installed the Oracle 10205 64-bit database and it is up and running. While I was going thru the SDN forum, I h

  • Need Information about WEB Gui

    Hi all, I need some informatin about web gui.  What is it? It's a web application or a internet services or what? How can I use it? IT's possible to use it in the enterprise portal? thanks enzo

  • INERNATIONAL DIALING IS NOT WORKING IN CME 10

    Dear Team, International dialing in CME is having issue. call is disconnecting automatically but still its hitting on the same Voice dialpeer. We had different cor list configured Local/national/international etc. Everything else is working fine but

  • Insert data in goods receipt PO

    hello: I am a newbie using SDK, and i have some problems when i use it. I have created some columns in the goods receipt PO form(Column weight1, weight2, weight3 in table PDN1). what I want do is to insert data into those columns by using the SDK whi