VARRAY as in put param in procedure

When I create a procedure to test VARRAY input param
create or replace procedure test_arr as
type va_roles is varray(10) of varchar2(24);
role1 va_roles := va_roles('a','s','f');
begin
user_mgmt.change_role(role1);
dbms_output.put_line('Count ' ||role1.count);
end;
PLS-00306: wrong number or types of arguments in call to 'CHANGE_ROLE'
create or replace package user_mgmt as
type va_roles is varray(3) of nvarchar2(24);
procedure change_role(pmirole IN va_roles);
end user_mgmt;
CREATE OR REPLACE PACKAGE BODY user_mgmt
AS
PROCEDURE change_role (
role1 IN va_roles
AS
BEGIN
for i in role1.first..role1.last
loop
dbms_output.put_line(role1(i));
end loop;
END change_role;
END user_mgmt;
---

Hi!
Pls check it --
SQL> create or replace package user_mgmt as
  2   type va_roles is varray(3) of nvarchar2(24);
  3   procedure change_role(pmirole IN va_roles);
  4  end user_mgmt;
  5  /
Package created.
SQL> ed
Wrote file afiedt.buf
  1  CREATE OR REPLACE PACKAGE BODY user_mgmt
  2  AS
  3   PROCEDURE change_role (pmirole IN va_roles)
  4   AS
  5   BEGIN
  6    for i in pmirole.first..pmirole.last
  7    loop
  8    dbms_output.put_line(pmirole(i));
  9    end loop;
10   END change_role;
11* END user_mgmt;
SQL> /
Package body created.Regards.
Satyaki De.

Similar Messages

  • VARRAYS - how to use in sub procedures and how to empty them?

    Hi!
    I made a procedure where i use three diffrent varrays. I got it working only after
    putting all code in one big MAIN-block. Looks nasty.
    If i try to use sub-procedures i allways got ORA-06531-message.
    = "Reference to uninitialized collection"
    How can i use varrays in sub-procedures? Is there some trick in delcare or in procedure call?
    I try to use IN OUT parameters, but i didn't get it working. Run out of time in trial and error, of cource...
    I seemed to me that varrays aren't same way usable allover in code as all other variables i have declared.
    Is it so?
    Now the MAIN-block is long as a year... I'm used to code short MAIN-block with many sub-procedures calls.
    (In same procedure, not different procedures in db).
    Another problem is how to empty a varray in effective way?
    I tried my_varray.DELELTE and my_varray.TRIM but they won't do the thing. These remove/trim the elements but i just need to
    empty varray before fetching a new line from db. If I my_varray := NULL; then that same ORA-06531 when next read/write in varray.
    Now i just use FOR i IN 1..120 LOOP
    my_varray(i) := NULL;
    END LOOP;
    but there must be better way, hope so.
    Cheers,
    SL

    You were rigth "3360" - i had three varrays too many. Just to the grabage bin and some recoding.
    The link you posted show me the way: Associative Arrays
    - easy to declare, easy to use, works fine in sub procedures. Great - just what i need.
    Thanks alot!
    I fully agree W. Robertson on this:
    "I often see questions on technical forums about arrays in PL/SQL, which type to use and what the differences are. Although the documentation has quite a lot to say on the subject, I feel it tries to introduce too many concepts at once and ends up being confusing, especially when it comes to choosing between VARRAYs and Nested Table collections, where most of the "which to use" advice is about collection columns of database tables (which you probably don't need), and not about PL/SQL at all."
    - sl -

  • To get the the out put of the procedure..help needed

    hi all,
    i have a procedure :
    CREATE OR REPLACE PROCEDURE EN_GetCategory
         StaffID IN      VARCHAR2 DEFAULT NULL,
         ResultCategory OUT      VARCHAR2
    AS
    v_exec_tx varchar2(2000);
         Condition VARCHAR2(1000);
         Category VARCHAR2(1);
         SQL_ADV VARCHAR2(2000);
         Cnt          NUMBER(10);
         Cnt1          NUMBER(10);
    CURSOR curCategory IS
    SELECT SMC.Category,SMC.Condition FROM ST_MS_Category SMC ORDER BY OrderRowNo;
         BEGIN
              EXECUTE IMMEDIATE 'TRUNCATE TABLE TMP';
              OPEN curCategory;
              FETCH curCategory INTO Category, Condition;
              while curCategory%FOUND
              LOOP
              BEGIN
                   v_exec_tx:='SELECT COUNT(*) FROM ST_EMPLOYEE WHERE StaffID=''' || EN_GETCATEGORY.STAFFID ||''' AND ' || EN_GETCATEGORY.CONDITION;
                   EXECUTE IMMEDIATE v_exec_tx into Cnt;
    IF Cnt > 0 THEN                              SELECT COUNT(*) INTO CNT1 FROM tmp ;
              IF CNT1> 0     THEN
                                       UPDATE tmp SET CAT = Category ;
              ELSE
                                       INSERT INTO tmp VALUES (Category );
              END IF;
              END IF;
              FETCH curCategory INTO Category, Condition;
                   END;
              END LOOP;
              CLOSE curCategory;
              BEGIN
                   FOR REC IN ( SELECT CAT FROM tmp
                   LOOP
                   EN_GetCategory.ResultCategory := REC.CAT;
                   END LOOP;
              END;
         END;
    i need to execute this procedure..
    i tried EXEC EN_GETCATEGORY('812005','');
    but getting error invalid sql statemnt..
    i think for this we have to write some more code can u please help to to find the output ofthis procedure..
    Thanks In advance

    Hi,
    i tried EXEC EN_GETCATEGORY('812005','');It's execute Procedure_name('Parameters');
    Regds.What tosh! "exec" is perfectly ok to use to call a procedure.
    The problem is with the OUT parameter. You need to declare a variable into which the OUT value can be put.

  • 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) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Passing varrays as parameters to a PLSQL procedure .

    Hi all,
    I have defined the following procedure :
    TYPE t_pc_list IS VARRAY(10) OF VARCHAR2(20);
    PROCEDURE get_pc_list (address IN VARCHAR2, code IN VARCHAR2,pc_list IN t_pc_list ) AS
    BEGIN
    NULL;
    END get_pc_list;
    But when calling it is allways saying : Error: PLS-00306: wrong number or types of arguments in call to 'GET_PC_LIST' .
    Best Regards.

    Use the same type. Try this code
    create or replace package imp_pack
    as
      TYPE t_pc_list IS VARRAY(10) OF VARCHAR2(20);
      procedure get_pc_list(addressId IN VARCHAR2, areaCode IN VARCHAR2,pc_list OUT t_pc_list );
    end imp_pack;
    create or replace package body imp_pack
    is
      PROCEDURE get_pc_list(addressId IN VARCHAR2, areaCode IN VARCHAR2,pc_list OUT t_pc_list )
      AS
      BEGIN
        NULL;
      END get_pc_list;
    end imp_pack;
    create or replace package control_pack
    as
      procedure get_pc_list;
    end;
    create or replace package body control_pack
    as
      PROCEDURE get_pc_list
      IS
        pc_list_a imp_pack.t_pc_list;
        pc_list_b imp_pack.t_pc_list;
        ls_address_id_a VARCHAR2(30);
        ls_area_code_a VARCHAR2(30);
        ls_address_id_b VARCHAR2(30);
        ls_area_code_b VARCHAR2(30);
      BEGIN
        imp_pack.get_pc_list(ls_address_id_a,ls_area_code_a,pc_list_a);
        null;
      END get_pc_list;
    end control_pack;
    /

  • Setting userdefined type param for procedure in java code

    hi all,
    i have to make the call to the procedure through java using callable statement. in that procedure i have one IN param type is user defined type. how to set that type value in java
    procedure name(
    pi_fundlist IN type_fundlist
    TYPE type_fundlist as TABLE OF obj_fundlist;
    TYPE obj_fundlist AS OBJECT
    strfundcd VARCHAR2(16)
    so i have to set the value for type_fundlist using callablestaement.
    please, can any body knows the solution.. reply soon

    Wang,
    PL/SQL record type does not map to any java class.
    Although I haven't tried it, I understand that you may be able to use JPublisher to create a mapping between PL/SQL record type and some java class[es].
    Alternatively, you can define an Oracle object type instead of a PL/SQL record type.
    (But you can't use "%type" when defining an object.)
    create or replace type BUSNS_ROLE as object (
      ID  number
    ,NM  varchar2(2000 char)
    ,DS  varchar2(4000 char)
    /Good Luck,
    Avi.

  • OUT Params in Procedure. Oracle 9

    I am new to PL/SQl, and im doing an asp .net site connectin to oracle using ODP
    I have written an procedure to take in Params and add a record to a DB, however I now want to use an OUT Param which will return a value to detemine whether the record already exists, this is my procedure, as you can see i have added an INOUT var called pv_exists, i want to check for the input records in my DB, is they exist i want the pv_exists to return a Zero to be site, any ideeas, im at a loss?
    CREATE OR REPLACE PROCEDURE HR_USER."SP_ADDPR" (pv_prtype varchar2, pv_team number,pv_year varchar2, pv_month varchar2, pv_alert date, pv_exists IN OUT number )
    IS
    pv_rowCount number;
    pv_tblid number;
    pv_text number;
    BEGIN
    select Count(*) Into pv_rowCount from TBLPR;
    if pv_rowCount > 0 then
    select Max(ID) + 1 into pv_tblid from TBLPR;
    Insert into TBLPR(id,PRType,PRTeamid,PRYEAR,PRMONTH,PRALERTDATE) Values (pv_tblid,pv_prtype,pv_team,pv_year,pv_month,pv_alert);
    else
    Insert into TBLPR(id,PRType,PRTeamid,PRYEAR,PRMONTH,PRALERTDATE) Values (1,pv_prtype,pv_team,pv_year,pv_month,pv_alert);
    end if;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    RAISE;
    END sp_AddPR;

    Cheer up, Hughesie
    create table tblpr(id          number(10)   not null
                      ,prtype      varchar2(10) not null
                      ,prteamid    varchar2(10) not null
                      ,pryear      number(4)    not null
                      ,prmonth     varchar2(12) not null
                      ,pralertdate date         not null
                      ,constraint tblpr_pk primary key (id));
    /* Not sure about the natural key, but use this to tell "if record exists" */
    create unique index tblrpr_ux1 on tblpr(prtype, prteamid);             
    create sequence tblpr_id_seq;
    create or replace package tblpr_te
    as
       subtype tblpr_rt is tblpr%rowtype;  
       subtype prtype_t is tblpr.prtype%type;
       subtype prteamid_t is tblpr.prteamid%type;
       subtype pryear_t is tblpr.pryear%type;
       subtype prmonth_t is tblpr.prmonth%type;
       subtype pralertdate_t is tblpr.pralertdate%type;
       procedure add(po_exists out pls_integer
                    ,pi_prtype in  prtype_t 
                    ,pi_team   in  prteamid_t
                    ,pi_year   in  pryear_t
                    ,pi_month  in  prmonth_t
                    ,pi_alert  in  pralertdate_t);
    end tblpr_te;
    create or replace package body tblpr_te
    as
       procedure add(po_exists out pls_integer
                    ,pi_prtype in  prtype_t 
                    ,pi_team   in  prteamid_t
                    ,pi_year   in  pryear_t
                    ,pi_month  in  prmonth_t
                    ,pi_alert  in  pralertdate_t)
       is
       begin
          insert into tblpr(id
                           ,prtype
                           ,prteamid
                           ,pryear
                           ,prmonth
                           ,pralertdate)
                   values (tblpr_id_seq.nextval
                          ,pi_prtype
                          ,pi_team
                          ,pi_year
                          ,pi_month
                          ,pi_alert);
          po_exists := 0;
       exception
       when dup_val_on_index
       then
          po_exists := 1;
       end add;   
    end tblpr_te;
    select * from tblpr;
    set serveroutput on
    declare
      l_exists pls_integer;
    begin
       tblpr_te.add(l_exists, 'A_Type', 'Some_Team', 2008, 'January', sysdate +12);
       commit;  
       dbms_output.put_line('l_exists: ' || l_exists);
    end;
    select * from tblpr;
    drop package tblpr_te;
    drop sequence tblpr_id_seq;
    drop table tblpr purge
    /Regards
    Peter

  • How to register OUT param to  RECORD type for STORED PROCEDURE???

    hi
    i have a SP like this
    CREATE OR REPLACE PACKAGE P1 AS
    TYPE g_con_ref_cursor is REF CURSOR ;
    TYPE g_con_error IS RECORD
      error_code NUMBER,
      error_desc varchar2(2000)
    PROCEDURE PROC_CURSOR
    (i_str_userid  IN VARCHAR2,
      o_cur_ref_cur OUT g_con_ref_cursor,
      o_rec_error   OUT g_con_error,
      o_num_status  OUT NUMBER);
    END;and now i am trying to call this SP using my java program
    i am able to register the out put params for 2nd and 4 th variable
    my doubt is how i can register the output param for 3rd (g_con_error) which is of record type
    and how i can get result from this ????
    my java program is like this
    Connection connection = DatabaseHelper.prepareConnection();
    CallableStatement proc = connection.prepareCall("{ call P1.PROC_CURSOR(?, ?, ?, ?) }");
    proc.setString(1,"jn26557");
    proc.registerOutParameter(2,oracle.jdbc.driver.OracleTypes.CURSOR);
    proc.registerOutParameter(3,???,????); //HOW TO SET  THIS ?????
    proc.registerOutParameter(4,oracle.jdbc.driver.OracleTypes.NUMERIC);
    proc.execute();plz help me in this
    i have no idea how to do it
    any help would be appreciated
    Thanks in advance
    Jaya Prakash Nalajala

    You might give a try using:
    proc.registerOutParameter(3, java.sql.Types.REF, "RECORD");

  • How to put Stored Procedure in Receiver JDBC channel

    Hi all,Good Evening,Iam using a JDBC to JDBC scenario in which I have to move the data from database into XI and we all know that the Interfaces which require stored procedures on Oracle database server for publishing the data needs to be called in combination of BPM & Receiver JDBC adapter.
            In this method, a dummy interface will be created for triggering the process. This interface could be designed using any adapter which works on polling mechanism (sender JDBC/File). Dummy interface will invoke a small BPM designed for each business object. BPM will make a synchronous call to Oracle database by calling underlying stored procedure. Stored procedure will return the result set by using a cursor. BPM will send this result set to target application.
            Now my question is how to put a stored procedure in a receiver JDBC channel which need to collect the data from database when BPM makes a synchronous call.
           Because it is required in my scenario,can any one tell me how and where to put stored Procedure in JDBC receiver channel.
    Thanks in advance,
    Regards,
    Prajwal

    Your action should be EXECUTE for stored procedures in Message mapping.
    <StatementName5>
    <storedProcedureName action=u201D EXECUTEu201D>
        <table>realStoredProcedureeName</table>
    <param1 [isInput=u201Dtrueu201D] [isOutput=true] type=SQLDatatype>val1</param1>
    </storedProcedureName > 
    </StatementName5>
    action=EXECUTE
    Statements with this action result in a stored procedure being executed. The name of the element is interpreted as the name of the stored procedure in the database. If you use the optional <table> element, the value specified here is used as the stored procedure name. This enables you, for example, to define stored procedure names containing non-XML-compatible characters or characters that prevent them from being used in interface definitions in the Integration Builder/PCK.  If specified, <table> must be the first element in the block within <dbTableName>.
    The elements within the stored procedure are interpreted as parameters. They can optionally have the attribute isInput=u201C1u201C (input parameter) or isOutput=u201C1u201C (output parameter) or both (INOUT parameter). If both attributes are missing, the element is interpreted as an input parameter. The parameter names must be identical to those of the stored procedure definition.
    The attribute type=<SQL-Datatype> , which describes the valid SQL data type, is mandatory for all parameter types (IN, OUT, INOUT).
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    /people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
    /people/sap.user72/blog/2005/10/15/jdbc-adapter-execution-mode-chained-or-unchained
    /people/luis.melgar/blog/2008/05/13/synchronous-soap-to-jdbc--end-to-end-walkthrough
    /people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi

  • VARRAY padding in procedure

    Hi all,
    Im a little new to this so please bear with me..
    I have created a type of VARRAY:
    CREATE OR REPLACE TYPE rows_of as VARRAY(10) OF CHAR;
    And a procedure that takes two of the types. What I want the procedure to do is pad out the lenth of sencond type being passed in with '-' charctor. Below is the procedure I have written but for some reason it keeps throwing me the error:
    ERROR at line 1:
    ORA-06533: Subscript beyond count
    ORA-06512: at "PADD", line 14
    ORA-06512: at line 6
    CREATE OR REPLACE PROCEDURE padd(row1 rows_of, row2 rows_of)
    IS
    count_entry NUMBER:=row1.LAST;
    count_test NUMBER:=row2.LAST;
    dummby_row rows_of:=rows_of();
    BEGIN
    dummby_row:=row2;
    IF (count_entry > count_test) THEN
    FOR i IN row2.LAST + 1 ..row1.LAST
    LOOP
    dummby_row(i):='-' ;
    END LOOP;
    END IF;
    END;
    show error
    This is the execution block I am sending:
    DECLARE
    row1 rows_of:=rows_of('3','7','2','3','-','-');
    row2 rows_of:=rows_of('-','-','3');
    answer rows_of;
    BEGIN
    padd(row1, row2);
    END;
    Could anyone help me out to where I am wrong? It has something to do with dummby_row(i):='-' ; but Ive tried different assignments and cannot get it to work.
    Thanks in advance!
    Stef

    I've just seen this one pass elsewhere ;)
    You assign row2 to dummby_row. Now dummby_row has no more records than row2, so your loop immediately goes wrong with the mentioned error. As a first line in the loop, add a
    dummby_row.extend();MHE

  • 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

  • PASSING A VARRAY as parameter in a procedure and returning the same VARRAY

    Hi,
    I am passing a varray as IN parameter to a procedure. I want to retreive the same VARRAY from the procedure.
    DECLARE
       TYPE str_array IS VARRAY (4) OF VARCHAR2 (50);
       v_array           str_array;  
       PROCEDURE process_array (
          v_str_array             str_array
       AS
       BEGIN
          FOR i IN v_str_array.FIRST .. v_str_array.LAST
          LOOP
             DBMS_OUTPUT.put_line ('Hello ' || v_str_array (i));
          END LOOP;
       END;
    BEGIN
       v_array    := str_array ('John', 'Paul', 'Ringo', 'George');
       process_array (v_array);
       -- can also pass unbound Str_Array
       --process_array (str_array ('John', 'Paul', 'Ringo', 'George'));
    --   DBMS_OUTPUT.put_line ('Hello ' || v_str_out_array (i));
    END;I want to change this procedure so that i will retreive the same as VARRAY out from the procedure.
    Can anyone help me on the same

       PROCEDURE process_array (
          v_str_array             IN OUT str_array
       )If your varray is large then you can try:
       PROCEDURE process_array (
          v_str_array             IN OUT NOCOPY str_array
       )but you should learn about possible side-effects if there is an error while executing the procedure. In short words: if you don't use NOCOPY and an error occurs during execution of process_array procedure then your varray is not changed - all chages to the value of your varray are 'rolled back'. If you use NOCOPY then it depends...

  • Help me in calling stored procedure and getting results

    hi
    i have a SP like this
    CREATE OR REPLACE PACKAGE P1 AS
    TYPE g_con_ref_cursor is REF CURSOR ;
    TYPE g_con_error IS RECORD
      error_code NUMBER,
      error_desc varchar2(2000)
    PROCEDURE PROC_CURSOR
    (i_str_userid  IN VARCHAR2,
      o_cur_ref_cur OUT g_con_ref_cursor,
      o_rec_error   OUT g_con_error,
      o_num_status  OUT NUMBER);
    END;
    and i now i am trying to call this SP using my java program
    i am able to register the out put params for 2nd and 4 th variable
    my doubt is how i can register the output param for g_con_errorand how i can get result from this ????
    my java program is like this
    Connection connection = DatabaseHelper.prepareConnection();
    CallableStatement proc = connection.prepareCall("{ call P1.PROC_CURSOR(?, ?, ?, ?) }");
    proc.setString(1,"jn26557");
    proc.registerOutParameter(2,oracle.jdbc.driver.OracleTypes.CURSOR);
    proc.registerOutParameter(3,Types.STRUCT,); //HOW TO SET  THIS ?????
    proc.registerOutParameter(4,oracle.jdbc.driver.OracleTypes.NUMERIC);
    proc.execute();
    plz help me in this
    i have no idea how to do it
    any help would be appreciated
    Thanks in advance
    Jaya Prakash Nalajala

    You have the requirements to build the stored procedure, what have you got so far?
    Post your attempt and any errors or issues that you might be experiencing. Writing the whole procedure for you (without the table structure even) is going to be difficult.

  • Procedure being a kind of report

    I'm creating some sql queries wich will be executed by some users throught the Oracle client PL/SQL, and I would like to put it in procedures.
    Each procedure for each Sql query.
    So a user would execute a procedure, filling the parameters, and it will return the result of the query.
    How can I do it?
    I did a procedure, I included the sql query, but oracle says that:
    Error: PLS-00428: an INTO clause is expected in this SELECT statement
    Do I need to set the output for the result of the procedure, or something similar to that?
    Thanks for any help.

    if you do that then it will ask for the param once while compiling the view for the first time and not everytime
    create view myview
    as select * from t11 where empno = '&no'
    this will create a view only for empno that you have passed as parameter
    if you do select * from myview it will have only record for the param that you have passed, it will not be dynamic and that is the whole purpose of having a view to get runtime transactions.
    if you ant to do it it is best to use a procedure and inside the procedure create a global temp table and populate it and the user can get the values out of that tables using whatever mechanism and work on it or wthin the procedure you can use utl_file function and create a file in the format that is required.
    Message was edited by:
    user647181

  • How to extract many procedures data into one procedure.

    Hi all,
    I have about 16 procedures which extracts a csv files every time we run
    Exec package.procedure1;
    Exec package.procedure2;
    Exec package.procedure3;
    I wish to stop doing this tedious operation(-_-)
    How to put all these procedures in an EXTRACT_ALL procedure.
    I tried something like this.But I think i am getting it all wrong.
    PROCEDURE extract_all_states
         IS
          outfile     UTL_FILE.file_type;
             curr_curs1   varchar2(4000);
             curr_curs2   varchar2(4000);
         BEGIN
         extract_Penang (curr_curs1);
                    extract_Selangor (curr_curs2);
         UTL_FILE.fclose (outfile);
       EXCEPTION
          WHEN UTL_FILE.invalid_mode
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Invalid Mode Parameter' || '  -  ' || (SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.invalid_path
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Invalid File Location' || '  -  ' ||(SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.invalid_filehandle
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Invalid Filehandle' || '  -  ' ||(SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.invalid_operation
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Invalid Operation' || '  -  ' || (SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.read_error
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Read Error' || '  -  ' || (SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.internal_error
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Internal Error' || '  -  ' || (SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.charsetmismatch
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message :=
                   'Opened With FOPEN_NCHAR But Later I/O Inconsistent'
                || '  -  '
                || SQLERRM;
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.file_open
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'File Already Opened' || '  -  ' ||(SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.invalid_maxlinesize
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Line Size Exceeds 32K' || '  -  ' ||(SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.invalid_filename
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Invalid File Name' || '  -  ' ||(SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.access_denied
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'File Access Denied By' || '  -  ' ||(SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN UTL_FILE.invalid_offset
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'FSEEK Param Less Than 0' || '  -  ' || (SQLERRM);
             RAISE gv_exp_generate_error;
          WHEN OTHERS
          THEN
             UTL_FILE.fclose (outfile);
             gv_error_message := 'Unknown UTL_FILE Error' || '  -  ' || (SQLERRM);
             RAISE gv_exp_generate_error;     
         END extract_all_states; 
       END states_pkg;Error(321,3): PLS-00306: wrong number or types of arguments in call to 'EXTRACT_PENANG'
    Error(321,3): PLS-00306: wrong number or types of arguments in call to 'EXTRACT_SELANGOR'
    null

    Why is it that your "tedious" manual operation shows no parameters to the procedures while your extract_all procedure has parameters?
    You need to call each of the individual procedures in exactly the same way as you do when you execute them individually at the command line. In your extract_all procedure, you are clearly not doing so, hence the "wrong number or types of arguments in call to"
    John

Maybe you are looking for