How to execute a procedure with Object as OUT parameter

Hi,
I have a procedure and it consists 2 parameter, one is an input parameter and that is some ID (NUMBER datatype) and 2nd parameter is an out parameter and it an Object type. I want to execute that procedure but not able to do the same. Can anyone please suggest me how do I execute a procedure which has got Object as an out parameter.
Thanks a lot in advance for your support.

Example:
SQL> create or replace type t_obj as object (ename varchar2(10), deptno number);
  2  /
Type created.
SQL> ed
Wrote file afiedt.buf
  1  create or replace procedure myproc (p_empno in number, obj out t_obj) is
  2  begin
  3    select t_obj(ename, deptno)
  4    into obj
  5    from emp
  6    where empno = p_empno;
  7* end;
SQL> /
Procedure created.
SQL> set serverout on
SQL> declare
  2    v_obj t_obj;
  3  begin
  4    myproc(7788, v_obj);
  5    dbms_output.put_line(v_obj.ename||','||v_obj.deptno);
  6  end;
  7  /
SCOTT,20
PL/SQL procedure successfully completed.

Similar Messages

  • How to execute a procedure with collection passed as parameter?

    i have created the collection:
    CREATE TYPE typ_Project AS OBJECT( project_no NUMBER(2), title VARCHAR2(35), cost NUMBER(7,2))
    CREATE TYPE typ_ProjectList AS VARRAY (50) OF typ_Project
    and a procedure:
    CREATE OR REPLACE PROCEDURE add_project (
    p_deptno IN NUMBER,
    p_new_project IN typ_Project,
    p_position IN NUMBER )
    IS
    v_my_projects typ_ProjectList;
    BEGIN
    SELECT projects INTO v_my_projects FROM department
    WHERE dept_id = p_deptno FOR UPDATE OF projects;
    v_my_projects.EXTEND;
    FOR i IN REVERSE p_position..v_my_projects.LAST - 1 LOOP
    v_my_projects(i + 1) := v_my_projects(i);
    END LOOP;
    v_my_projects(p_position) := p_new_project; -- add new
    UPDATE department SET projects = v_my_projects
    WHERE dept_id = p_deptno;
    END add_project;
    Now please explain how to call this procedure with collection passed as parameter . . .

    For example:
    BEGIN
        add_project(
                    10, -- department number
                    typ_Project(
                                99, -- project number
                                'New Project', -- project title
                                99999.99 -- project cost
                               ), -- new project
                    5 -- project position
    END;
    /SY.

  • Stored procedure with cursor as out parameter

    Can any one help me by showing how to write a procedure with cursor as out parameter and caputuring it in java using jdbc.
    Thanks in advance,
    shravan bharadwaj

    I know that in the SQLJ distribution (which is also downloadable) there is an example in the demo directory called RefCursDemo that shows the SQL code and how to call it - albeit from SQLJ and not JDBC. There may also be a demo in the JDBC distribution, though I am not sure about that.

  • Call from Java Plsql Procedure with VArray as Out Parameter

    Hi,
    I have a Java web application(Tomcat server) that call a plsql procedure with Varray as OUT parameter.
    The Plsql code is perfectly compiled.
    When i run the application, I get the following error msg in my Tomcat window:
    java.sql.SQLException: ORA-06530: Reference to uninitialized composite
    ORA-06512: at "SEMS1.PACK_SEMSADMIN_OFFEREDJOBS", line 102
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:109
    3)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
    {color:#0000ff}
    Doubt: Do I need to declare ArrayDescriptors to retrieve the VArray from the Plsql procedure.
    I think the below statement is enough; we need ArrayDescriptors only when we we wish to send a Plsql Object or Varray from Java code to the procedure. Plz correct me if not so.
    dbCallableStatement.execute();
    ARRAY SimpleOUTArray = (ARRAY) ((OracleCallableStatement) dbCallableStatement).
    getObject(Integer.parseInt(arlParameterOutIndex.get(i).toString()));{color}
    I am unable to realize where the mistake is?
    {color:#800000}
    {color}{color:#800000}
    VARRAY AND PROC DETAILS:
    TYPE STRUCT_JOB_DETAILS AS OBJECT
    APPL_NO NUMBER (10),
    S_FNAME VARCHAR2 (32 Byte),
    S_MI VARCHAR2 (32 Byte),
    S_LNAME VARCHAR2 (32 Byte),
    APPL_DATE DATE,
    DESCRIPTION VARCHAR2 (100 Byte),
    S_UCID VARCHAR2 (8 Byte)
    TYPE VARRAY_JOB_DETAILS IS VARRAY(100) OF STRUCT_JOB_DETAILS;{color}
    {color:#800000}PROCEDURE:{color}
    {color:#800000}CREATE OR REPLACE PACKAGE PACK_SEMSADMIN_OFFEREDJOBS
    AS
    TYPE Generic_Cursor_Type IS REF CURSOR;
    --TYPE varray_job_detail is VARRAY(100) OF STRUCT_JOB_DETAILS;
    --va_varray_job_detail varray_job_detail := varray_job_detail();
    va_varray_job_detail VARRAY_JOB_DETAILS := VARRAY_JOB_DETAILS();
    PROCEDURE Admin_Jobs_Offered_Rtr
    ic_status IN VARCHAR2,
    or_offered_jobs OUT Generic_Cursor_Type,
    va_varray_job_detail OUT VARRAY_JOB_DETAILS
    CREATE OR REPLACE PACKAGE BODY PACK_SEMSADMIN_OFFEREDJOBS
    AS
    PROCEDURE Admin_Jobs_Offered_Rtr
    ic_status IN VARCHAR2,
    or_offered_jobs OUT Generic_Cursor_Type,
    va_varray_job_detail OUT VARRAY_JOB_DETAILS
    AS
    vc_query VARCHAR2(15000) := '';
    vc_query_1 VARCHAR2(15000) := '';
    counter NUMBER := 1;
    vc_no NUMBER := 0;
    or_applicants_list Generic_Cursor_Type;
    TYPE type_appln_list IS RECORD
    job_no NUMBER(10),
    job_title VARCHAR2(50 BYTE),
    account_no VARCHAR2(10 BYTE),
    head_fname VARCHAR2(32 BYTE),
    head_minitial VARCHAR2(10 BYTE),
    head_lname VARCHAR2(32 BYTE),
    num NUMBER
    vn_appln_list type_appln_list;
    TYPE type_job_offered IS RECORD
    APPL_NO NUMBER (10),
    S_FNAME VARCHAR2 (32),
    S_MI VARCHAR2 (32),
    S_LNAME VARCHAR2 (32),
    APPL_DATE DATE,
    DESCRIPTION VARCHAR2 (100),
    S_UCID VARCHAR2 (8)
    vn_job_offered type_job_offered;
    BEGIN
    vc_query := vc_query || ' SELECT jobs.job_no,job_title, account_no, head_fname, head_minitial, head_lname, num';
    vc_query := vc_query || ' FROM jobs, ( ' ;
    vc_query := vc_query || ' SELECT jobs.job_no,count(*) as num' ;
    vc_query := vc_query || ' FROM student_apps ,jobs ' ;
    vc_query := vc_query || ' WHERE jobs.job_no = student_apps.job_no' ;
    vc_query := vc_query || ' AND (student_apps.status in (''o'',''t'')) '; --|| ic_status || ')' ;
    vc_query := vc_query || ' AND jobs.status not in (''z'', ''Z'')' ;
    vc_query := vc_query || ' GROUP BY jobs.job_no' ;
    vc_query := vc_query || ' ) no_apps_off' ;
    vc_query := vc_query || ' WHERE jobs.job_no = no_apps_off.job_no' ;
    dbms_output.put_line('Executed Query_1');
    va_varray_job_detail := VARRAY_JOB_DETAILS();
    va_varray_job_detail.extend(100);
    OPEN or_offered_jobs FOR vc_query;
    LOOP
    FETCH or_offered_jobs INTO vn_appln_list;
    EXIT WHEN or_offered_jobs%NOTFOUND;
    vc_query_1 := '';
    vc_query_1 := vc_query_1 || ' SELECT stud_apps.appl_no APPL_NO, stud_apps.s_fname S_FNAME, ';
    vc_query_1 := vc_query_1 || ' stud_apps.s_mi S_MI, stud_apps.s_lname S_LNAME, ';
    vc_query_1 := vc_query_1 || ' stud_apps.appl_date APPL_DATE, look_up.description DESCRIPTION, ' ;
    vc_query_1 := vc_query_1 || ' stud_apps.s_ucid S_UCID ' ;
    vc_query_1 := vc_query_1 || ' FROM student_apps stud_apps,jobs jbs,lookup look_up' ;
    vc_query_1 := vc_query_1 || ' WHERE stud_apps.status in (''o'',''t'') '; --(' || ic_status || ') ' ;
    vc_query_1 := vc_query_1 || ' AND jbs.job_no = stud_apps.job_no' ;
    vc_query_1 := vc_query_1 || ' AND jbs.status not in (''z '', ''Z'')' ;
    vc_query_1 := vc_query_1 || ' AND stud_apps.status = look_up.code ' ;
    vc_query_1 := vc_query_1 || ' AND look_up.type = ''st''' ;
    vc_query_1 := vc_query_1 || ' AND stud_apps.job_no = ''' || vn_appln_list.job_no || ''' ' ;
    vc_query_1 := vc_query_1 || ' ORDER BY appl_date' ;
    dbms_output.put_line('Executed Query_2');
    OPEN or_applicants_list FOR vc_query_1;
    LOOP
    FETCH or_applicants_list INTO vn_job_offered;
    EXIT WHEN or_applicants_list%NOTFOUND;
    va_varray_job_detail(counter).APPL_NO := vn_job_offered.APPL_NO;
    va_varray_job_detail(counter).S_FNAME := vn_job_offered.S_FNAME;
    va_varray_job_detail(counter).S_MI := vn_job_offered.S_MI;
    va_varray_job_detail(counter).S_LNAME := vn_job_offered.S_LNAME;
    va_varray_job_detail(counter).APPL_DATE := vn_job_offered.APPL_DATE;
    va_varray_job_detail(counter).DESCRIPTION := vn_job_offered.DESCRIPTION;
    va_varray_job_detail(counter).S_UCID := vn_job_offered.S_UCID;
    counter := counter + 1;
    END LOOP; --end of FOR
    CLOSE or_applicants_list;
    END LOOP; -- end of FETCH
    END Admin_Jobs_Offered_Rtr;
    END PACK_SEMSADMIN_OFFEREDJOBS;
    /{color}
    Reqire help plzzzz !!!
    Thanks.

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • How can we execute a procedure with object type as its parameter, by passing partial elements.

    Can somebody help...
    I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
    PROCEDURE p_save (example IN OUT xyz_obj)
    my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
    And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.

    user13026549 wrote:
    Can somebody help...
    I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
    PROCEDURE p_save (example IN OUT xyz_obj)
    my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
    And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.
    It ISN'T possible. How could it be? Each attribute has to be set to something don't you think?
    A common way to handle that is to define a public package variable that is an instance of the object type and has ALL elements set to null. As Odie suggested a custom constructor function can be used for that.
    Then you create your procedure instance by starting with an instance of the package variable (where everything is null) and setting values for the attributes you need.

  • With JDBC, calling a stored procedure with ARRAY as out parameter

    Hi,
    I want to use the data type ARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
    my java program using JDBC.
    The problem it's i use a 8.1.7 client to acces with oci to a 7.1.3 Database.
    With this configuration I can get back a Cursor but not an Array.
    Does it's possible ?
    Thanks for your help !
    Michakl

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Calling a stored procedure with VARRAY as out parameter using JDBC

    Hi,
    I want to use the data type VARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
    my java program using JDBC.
    I'm using Oracle 8.1.5 for Windows NT.
    Please help me.
    Thanks
    Sumanta
    null

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Procedure with table type out parameter

    Hi,
    I need to create a procedure which gives back a content of a table as an out parameter.
    i have tried something like below code
    it might not be correct since i am writing from home and cannot access any oracle db right now
    create or replace procedure test (
    table_out test_table%rowtype
    ) as
    type table_out test_table%rowtype
    begin
    select * into table_out
    from test_table
    where country = 'HUN';
    end;
    compile doesnt gives error, but when running it i get error
    declare
    table_out test_table%rowtype
    begin
    test( table_out );
    dbms_output.put_line( table_out );
    end;
    but it fails, could you help how to solve the above problem and call the proc correctly?
    thanks in advance

    Well you said you want the content of a table but your example says you just want a record. So for a record:
    CREATE OR REPLACE PROCEDURE sp_test (EMP_REC OUT EMP%ROWTYPE) IS
    BEGIN
        select * into emp_rec from emp where empno = 7369;
    END;The anonymous block to run it might be:
    declare
    tab_out emp%rowtype;
    begin
    sp_test(tab_out);
    dbms_output.put_line(tab_out.ename);
    end;As damorgan said the dbms_output can't be used with the record type. Notice I used it for the ENAME value of the record.
    If you really want the entire table then do it the way damorgan suggests. A pipeline function can give you the table but not as an OUT parameter.

  • Stored procedure with IN and OUT parameter

    HI all,
    here is code example
    declare
             in_dt date  := '1-feb-2010' ;
    col1 ...;
    col2 ...;
    col3 ...;       
    begin
      select e.*
      into col1,
            col2,
            col3
      from table_xyz e
      where e.start_dt  = in_dt;
    end;
    How do i convert the above code into stored procedure by accepting "in_dt" as IN parameter and getting the result set displayed (output) through OUT parameter say "cur_out" (OUT paramter)
    Thank you so much !!! I really appriciate it !!

    i ran my procedure which is very similar syndra posted
    create or replace procedure foo(p_dt in date, cv out sys_refcursor) as
    begin
    open cv for
    select e.*
    from table_xyz e
    where start_dt = p_dt;
    end;
    /Here is how is executed
    DECLARE
      P_DT DATE;
      CV SYS_REFCURSOR;
    BEGIN
      P_DT := '10-oct-2005';
      -- CV := NULL;  Modify the code to initialize this parameter
      scott.foo ( P_DT, CV );
      COMMIT;
    END;           
    -- i get PL/SQL procedure successfully complted , But i dont see the result set Or output
    - How do i see the output when i m using refcursor ?? i tried using print , but nothing didnt work
    - Any idea ??
    Thank you!!
    Edited by: user642297 on Jun 24, 2010 1:35 PM

  • How to Execute a SP with onlly one OUTPUT parameter.

    I have SP as:-
    CREATE OR REPLACE PROCEDURE spt_remove_duplicates_pr (outbuffer OUT VARCHAR2)
    IS
    buff VARCHAR2(32000) := ' ';
    BEGIN
    buff := ' Hi From Stored Proc' ;
    outbuffer : = buff;
    END;
    How can I execute it and get the output result ?
    I have tried as
    declare
    buff VARCHAR2(32000) := '';
    begin
    select (exec spt_remove_duplicates_pr(buff)) into buff from dual;
    DBMS_OUTPUT.put_line (buff);
    end;
    END;
    but getting errors as : -
    ORA-06550 line string, column string:string
    Cause: A PL/SQL compilation error has occurred. The numbers given for line and column are the location in the PL/SQL block where the error occurred.
    Please help.

    Probably I was being hasty in my assumptions. If you really need a procedure, use it like the following.
    SQL> l
    1 CREATE OR REPLACE PROCEDURE spt_remove_duplicates_pr (outbuffer OUT V
    2 IS
    3 buff VARCHAR2(32000) := ' ';
    4 BEGIN
    5 buff := ' Hi From Stored Proc' ;
    6 outbuffer : = buff;
    7
    8* END;
    SQL> /
    Warning: Procedure created with compilation errors.
    SQL> show errors
    Errors for PROCEDURE SPT_REMOVE_DUPLICATES_PR:
    LINE/COL ERROR
    6/11 PLS-00103: Encountered the symbol ":" when expecting one of the
    following:
    := . ( @ % ;
    SQL> 6 outbuffer := buff;;
    SQL> /
    Procedure created.
    SQL> declare
    2 b varchar2(128);
    3 begin
    4 spt_remove_duplicates_pr(b);
    5 dbms_output.put_line(b);
    6 end;
    7 /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on size 1000000
    SQL> /
    Hi From Stored Proc
    PL/SQL procedure successfully completed.
    SQL>
    Just a side note, you got an error in line 6 of your procedure. In assignment operator :=
    there must not be any symbols (including spaces) between : and =
    Vlad Sadilovskiy
    Oracle Database Tools
    http://www.fourthelephant.com

  • Executing a Procedure with IN and OUT parameters

    How do I call/execute the following procedure? When I call as Courses(StartDate,EndDate,nCount,State,LastUpdate);
    I get an error:
    Error(92,45): PLS-00363: expression 'nCount' cannot be used as an assignment target
    Error(92,55): PLS-00363: expression 'State' cannot be used as an assignment target
    PROCEDURE  Courses
       StartDate       IN             VARCHAR2
    ,  EndDate        IN             VARCHAR2
    ,  nCount           IN OUT   VARCHAR2
    ,  State               IN OUT   CHAR
    ,  LastUpdate   IN             DATE

    set serverout on
    declare
       l_StartDate    VARCHAR2(100) := '20130101';  -- why are you using varchar? use a date! you WILL regret using a string eventually
       l_EndDate      VARCHAR2(100) := '20140101';
       l_Count        VARCHAR2(100);   -- string, again? why? isn't a count a number?
       l_State        VARCHAR2(100);
       l_LastUpdate   DATE     :=  sysdate;
    begin
       Courses ( l_StartDate, l_EndDate, l_Count, l_State, l_LastUPdate );
       dbms_output.put_line ( 'Count: ' || l_Count );
       dbms_output.put_line ( 'State: ' || l_State );
    end;

  • How to call (in PL/SQL) a Procedure with a VARRAY OUT parameter

    Please help, I always get this error:
    PLS-00306: wrong number or types of arguments in call to 'GET_ITEM'
    It's a simple procedure, what is wrong?
    create or replace
    package XXVDF_XPOS_NEW_SALE_TEST as
         type serial_nos               is varray(200)     of     varchar2(20);
    procedure get_item
    (P_SERIALS           IN serial_nos);
    end XXVDF_XPOS_NEW_SALE_TEST;
    create or replace
    package body XXVDF_XPOS_NEW_SALE_TEST as
    procedure get_item
         (P_SERIALS          IN serial_nos)
    is
    begin
         p_serials(1) := 'sdw';
    end get_item;
    end XXVDF_XPOS_NEW_SALE_TEST;
    declare
         type serial_nos               is varray(200) of     varchar2(20);
         P_SERIALS          serial_nos := serial_nos();
    begin
    null;
         XXVDF_XPOS_NEW_SALE_TEST.get_item(P_SERIALS);
         dbms_output.put_line('P_SERIAL_NUMBERS ' ||P_SERIALS(1));
    end;
    thanks, Steve White

    Correction those INs should say OUT:
    create or replace
    package XXVDF_XPOS_NEW_SALE_TEST as
         type serial_nos               is varray(200)     of     varchar2(20);
    procedure get_item
    (P_SERIALS           OUT serial_nos);
    end XXVDF_XPOS_NEW_SALE_TEST;
    create or replace
    package body XXVDF_XPOS_NEW_SALE_TEST as
    procedure get_item
         (P_SERIALS          OUT serial_nos)
    is
    begin
         p_serials(1) := 'sdw';
    end get_item;
    end XXVDF_XPOS_NEW_SALE_TEST;
    declare
         type serial_nos               is varray(200) of     varchar2(20);
         P_SERIALS          serial_nos := serial_nos();
    begin
    null;
         XXVDF_XPOS_NEW_SALE_TEST.get_item(P_SERIALS);
         dbms_output.put_line('P_SERIAL_NUMBERS ' ||P_SERIALS(1));
    end;
    ========
    XXVDF_XPOS_NEW_SALE_TEST.get_item(P_SERIALS);
    ERROR at line 7:
    ORA-06550: line 7, column 2:
    PLS-00306: wrong number or types of arguments in call to 'GET_ITEM'
    ORA-06550: line 7, column 2:
    PL/SQL: Statement ignored

  • How to call procedure with Object types in java

    Hi,
    We have procedure declaration as follows
    ===============
    TYPE TEST_TYPE AS OBJECT (NAME VARCHAR2(10));
    TYPE TESTTYPE1 AS object (student1 TESTTYPE,student2 TESTTYPE,student3 TESTTYPE);
    TYPE rect AS OBJECT
    -- The type has 3 attributes.
    length NUMBER,
    width NUMBER,
    area NUMBER,
    -- Define a constructor that has only 2 parameters.
    CONSTRUCTOR FUNCTION rect(length NUMBER, width NUMBER)
    RETURN SELF AS RESULT
    PROCEDURE G(obj1 in TESTTYPE1,obj2 out rect) as
    n1 testtype;
    n2 testtype;
    n3 testtype;
    n4 testtype;
    begin
    obj2 := NEW rect(10,20,200);
    n1 := obj1.student1;
    n2 := obj1.student2;
    n3 := obj1.student3;
    obj2.length :=20;
    end;
    =====================================================
    I am not able to call the procedure in java code as I cannot figure out which out parameter type will it be registered using registeroutparameter. using cursor or struct type fails.
    please let me know how I can pass values from stored procedure with objects to java.

    I'm not sure what you're trying to accomplish with your procedure, but in general, this is an example of how you could use oracle.sql.STRUCT.
    First, prepare your java.sql.CallableStatement using java.sql.CallableStatement cStmt = java.sql.Connection.prepareCall({ call G(?, ?) });
    Note that you don't have to use the OracleCallableStatement. The java.sql.CallableStatement will work just fine.
    For the IN parameter, you need to create three TEST_TYPE objects. Then you need to create one TESTTYPE1 object.
    These will all be instances of oracle.sql.STRUCT.
    To create a oracle.sql.STRUCT object you need a descriptor and a set of attributes. For example, to create a TEST_TYPE object you would do the following
    1. StructDescriptor sd = StructDescriptor.createDescriptor("TEST_TYPE", java.sql.Connection).
    2. Add a VARCHAR2 attribute to an array of attributes (e.g. Object[] attributes = new Object[]{"Student Name"})
    3. oracle.sql.STRUCT struct = new oracle.sql.STRUCT(sd, java.sql.Connection, attributes)
    Then do something similar to create the TESTTYPE1 object, except that the attribute array will contain three instances of TEST_TYPE struct objects.
    To bind the IN parameter you need to use the java.sql.CallableStatement.setObject(1, <Instance of TESTTYPE1 object>).
    To register the OUT parameter, you need to call java.sql.CallableStatement.registerOutParameter(2, oracle.jdbc.OracleTypes.STRUCT, "RECT").
    Then, execute your procedure using cStmt.execute();
    Retrieve your OUT parameter using oracle.sql.STRUCT struct = (oracle.sql.STRUCT)cStmt.getObject(2).
    Once you've done that, to get the values of the attributes of all of your STRUCT objects, you need their descriptors and their metadata.

  • How to write a shell script to execute a procedure with out parameter

    Hi,
    How to write a shell script to execute a procedure with out parameter.
    here is my procedure
    PROCEDURE sample(invar1 VARCHAR2,
    invar2 VARCHAR2,
    invar3 VARCHAR2,
    invar4 VARCHAR2,
    ecode out number);
    Any example really helpfull
    Thanks in advance

    Or if we're passing values in, maybe something like:
    Test procedure:
    CREATE OR REPLACE PROCEDURE p (myin IN VARCHAR2, myout OUT VARCHAR2)
    AS
    BEGIN
        myout :=
            CASE myin
                WHEN 'A' THEN 'APPLE'
                WHEN 'B' THEN 'BANANA'
                ELSE 'STARFRUIT'
            END;
    END;Shell script:
    #!/bin/bash
    my_shell_variable=$1
    unset ORACLE_PATH
    sqlplus -s un/pw@db <<-EOF
    set feedback off pause off
    set pagesize 0
    set autoprint off
    VAR out varchar2(30)
    VAR myin varchar2(30)
    exec :myin := '${my_shell_variable}'
    BEGIN
      p(:myin, :out);
    END;
    print out
    exit
    EOFTest:
    /Users/williamr: xx A
    APPLE
    /Users/williamr: xx B
    BANANA
    /Users/williamr: xx
    STARFRUITObviously in a real script you would not hardcode the password or let it show in a "ps" listing.
    Message was edited by:
    William Robertson

  • How to execute the procedure in sap b1

    Hai to all,
                 I done a procedure in sql server .but i don't know how to execute that  procedure in sap b1?
    can anyone help me immediately.
    Regards,
    Ramya.S

    Dear Ramya.S,
    You could execute the store procedure by using Recordset object in SDK DI code. It is like:
    Dim myRecordSet As SAPbobsCOM.Recordset
    myRecordSet =                                   
    SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecord
    set)
    myRecordSet.Command.Name = "TestStoredProcedure"
    myRecordSet.Command.Parameters.Item("@ItemLike").Value = "IT%"
    myRecordSet.Command.Parameters.Item(2).Value = "C0001"
    myRecordSet.Command.Execute()

Maybe you are looking for

  • Purchase Order with Transaction Type: Missing on scrren

    Hi Guys, I've been searching for the place in config and master data that determines where the Transaction type is linked the the org. unit or user, but have not been succesfull. The selection for transaction type is emty in the "Create Purchase orde

  • Grouping PM

    Have development task to tag all boiler components to create PM system. Two questions. Do you really need to tag everything(its 4 floors) can you utilize prints, scheduled, and spreadsheet matrix? and CMMS system is old FAMIS version 3 2007 to create

  • Colors are muted when opened in PS CS5, they look fine in LR & Bridge

    All of sudden when opening files in photoshope cs5 the colors are muted.  They look normal in bridge and lightroom.  I was not having this problem before, it just all of sudden happened.  Any suggestions would be appreciated.

  • DV9890ea

    I  paid a lot of money for this laptop a few years ago and it is out of warranty. I have the same problem as many other owners have reported. The computer just shuts down for no reason. I have to remove battery and re-install to be able to reboot it.

  • Buying hardware with installed Adobe products

    Hi there, I was looking at some eBay auctions and found that there are laptop sold with Adobe Master Collection. I asked one seller and he told me this is some kind of group license and I wouldn't be able to register under my own name. Personally I t