Write in table type pl sql

Hi,
i want to read/write from/to a table type in pl sql procedure.
I have this:
in the declaration of package I have:
......more code more code...
type type1 is record ( field1 varchar2(4000), field2 varchar2(4000), filed3 number);
rec type1;
type table_example is table of rec%type index by binary_integer;
...more code more code...
In the body of my package i have a procedure in which i want to write/read into/from table_ex (table_ex is a variable of type table_example;)
How could i do?
Could you all post some code of example (in particular i want to update fields of table_ex)?
Please help.
Thanks

Hi,
I think you need some package for manage simple task againts your table. It's called package API. I created a package API for example for you (this package it's only a little example):
Example table:
-- Create table
create table TEST
  AD_TEST NUMBER(10) not null,
  NM_TEST VARCHAR2(30) not null
-- Create/Recreate primary, unique and foreign key constraints
alter table TEST
  add constraint PK_TEST_1 primary key (AD_TEST)
  using index;Sequence...
-- Create sequence
create sequence SEQ_TEST
minvalue 1
maxvalue 99999999999999999999
start with 1
increment by 1
cache 20;Package API for table test
CREATE OR REPLACE PACKAGE pack_api_test IS
   TYPE t_ref_cur IS REF CURSOR;
   PROCEDURE proc_ins_test(p_ad_test OUT test.ad_test%TYPE,
                           p_nm_test IN test.nm_test%TYPE,
                           p_return  OUT NUMBER,
                           p_message OUT VARCHAR2);
   PROCEDURE proc_upd_test(p_ad_test IN test.ad_test%TYPE,
                           p_nm_test IN test.nm_test%TYPE,
                           p_return  OUT NUMBER,
                           p_message OUT VARCHAR2);
   PROCEDURE proc_sch_test(p_rec_test OUT test%ROWTYPE,
                           p_ad_test  IN test.ad_test%TYPE,
                           p_return   OUT NUMBER,
                           p_message  OUT VARCHAR2);
   PROCEDURE proc_lis_test(p_ad_test IN test.ad_test%TYPE,
                           p_nm_test IN test.nm_test%TYPE,
                           p_query   OUT t_ref_cur,
                           p_return  OUT NUMBER,
                           p_message OUT VARCHAR2);
END pack_api_test;
CREATE OR REPLACE PACKAGE BODY pack_api_test IS
   -- Package constants
   P_RETURN_SUCCESFUL  CONSTANT NUMBER(4) := 0;
   P_RETURN_ERROR      CONSTANT NUMBER(4) := 1;
   P_MESSAGE_SUCCESFUL CONSTANT VARCHAR2(100) := 'Succesful';
   PROCEDURE proc_ins_test(p_ad_test OUT test.ad_test%TYPE,
                           p_nm_test IN test.nm_test%TYPE,
                           p_return  OUT NUMBER,
                           p_message OUT VARCHAR2) IS
   BEGIN
      p_return  := P_RETURN_SUCCESFUL;
      p_message := P_MESSAGE_SUCCESFUL;
      INSERT INTO test a
         (a.ad_test,
          a.nm_test)
      VALUES
         (seq_test.NEXTVAL,
          p_nm_test)
      RETURNING ad_test INTO p_ad_test;
   EXCEPTION
      WHEN DUP_VAL_ON_INDEX THEN
         p_return  := P_RETURN_ERROR;
         p_message := 'Record already exists';
      WHEN OTHERS THEN
         p_return  := P_RETURN_ERROR;
         p_message := SQLERRM;
   END proc_ins_test;
   PROCEDURE proc_upd_test(p_ad_test IN test.ad_test%TYPE,
                           p_nm_test IN test.nm_test%TYPE,
                           p_return  OUT NUMBER,
                           p_message OUT VARCHAR2) IS
      generic_error EXCEPTION;
      data_not_updated_error EXCEPTION;
      v_rec_test test%ROWTYPE;
   BEGIN
      p_return  := P_RETURN_SUCCESFUL;
      p_message := P_MESSAGE_SUCCESFUL;
      proc_sch_test(p_rec_test => v_rec_test,
                    p_ad_test  => p_ad_test,
                    p_return   => p_return,
                    p_message  => p_message);
      IF p_return <> 0 THEN
         RAISE generic_error;
      END IF;
      UPDATE test a SET a.nm_test = p_nm_test WHERE ad_test = p_ad_test;
      IF (SQL%ROWCOUNT = 0) THEN
         RAISE data_not_updated_error;
      END IF;
   EXCEPTION
      WHEN generic_error THEN
         NULL;
      WHEN data_not_updated_error THEN
         p_return  := P_RETURN_ERROR;
         p_message := 'Data not updated';
      WHEN OTHERS THEN
         p_return  := P_RETURN_ERROR;
         p_message := SQLERRM;
   END proc_upd_test;
   PROCEDURE proc_sch_test(p_rec_test OUT test%ROWTYPE,
                           p_ad_test  IN test.ad_test%TYPE,
                           p_return   OUT NUMBER,
                           p_message  OUT VARCHAR2) IS
   BEGIN
      p_return  := P_RETURN_SUCCESFUL;
      p_message := P_MESSAGE_SUCCESFUL;
      SELECT * INTO p_rec_test FROM test a WHERE a.ad_test = p_ad_test;
   EXCEPTION
      WHEN NO_DATA_FOUND THEN
         p_return  := P_RETURN_ERROR;
         p_message := 'Record doesn''t exist';
      WHEN OTHERS THEN
         p_return  := P_RETURN_ERROR;
         p_message := SQLERRM;
   END proc_sch_test;
   PROCEDURE proc_lis_test(p_ad_test IN test.ad_test%TYPE,
                           p_nm_test IN test.nm_test%TYPE,
                           p_query   OUT t_ref_cur,
                           p_return  OUT NUMBER,
                           p_message OUT VARCHAR2) IS
      v_ds_sql VARCHAR2(4000);
   BEGIN
      p_return  := P_RETURN_SUCCESFUL;
      p_message := P_MESSAGE_SUCCESFUL;
      v_ds_sql := v_ds_sql || 'SELECT * ';
      v_ds_sql := v_ds_sql || 'FROM test ';
      v_ds_sql := v_ds_sql || 'WHERE 1 = 1 ';
      IF (p_ad_test IS NOT NULL) THEN
         v_ds_sql := v_ds_sql || 'AND ad_test = ' || p_ad_test || ' ';
      END IF;
      IF (p_nm_test IS NOT NULL) THEN
         v_ds_sql := v_ds_sql || 'AND nm_test like ''' || p_nm_test || ''' ';
      END IF;
      OPEN p_query FOR v_ds_sql;
   EXCEPTION
      WHEN OTHERS THEN
         p_return  := P_RETURN_ERROR;
         p_message := SQLERRM;
   END proc_lis_test;
END pack_api_test;
/Regards,

Similar Messages

  • Syntax error when creating a user-defined table type in SQL Server 2012

    Why am I getting a syntax error when creating a user-defined table type in SQL Server 2014?
    CREATE TYPE ReportsTableType AS TABLE 
    ( reportId INT
    , questionId INT
    , questionOrder INT );
    Results:
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'AS'.

    Hope these posts could help, 
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/37a45a9a-ed8c-4655-be93-f6e6d5ef44be/getting-incorrect-syntax-while-creating-a-table-type-in-sql-server-2008-r2?forum=transactsql
    Regards, Dineshkumar,
    Please Mark as Answer if my post answers your question and
    Vote as Helpful if it helps you

  • Managing statistics for object collections used as table types in SQL

    Hi All,
    Is there a way to manage statistics for collections used as table types in SQL.
    Below is my test case
    Oracle Version :
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> Original Query :
    SELECT
         9999,
         tbl_typ.FILE_ID,
         tf.FILE_NM ,
         tf.MIME_TYPE ,
         dbms_lob.getlength(tfd.FILE_DATA)
    FROM
         TG_FILE tf,
         TG_FILE_DATA tfd,
              SELECT
              FROM
                   TABLE
                        SELECT
                             CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                             OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
                        FROM
                             dual
         )     tbl_typ
    WHERE
         tf.FILE_ID     = tfd.FILE_ID
    AND tf.FILE_ID  = tbl_typ.FILE_ID
    AND tfd.FILE_ID = tbl_typ.FILE_ID;
    Elapsed: 00:00:02.90
    Execution Plan
    Plan hash value: 3970072279
    | Id  | Operation                                | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                         |              |     1 |   194 |  4567   (2)| 00:00:55 |
    |*  1 |  HASH JOIN                               |              |     1 |   194 |  4567   (2)| 00:00:55 |
    |*  2 |   HASH JOIN                              |              |  8168 |   287K|   695   (3)| 00:00:09 |
    |   3 |    VIEW                                  |              |  8168 |   103K|    29   (0)| 00:00:01 |
    |   4 |     COLLECTION ITERATOR CONSTRUCTOR FETCH|              |  8168 | 16336 |    29   (0)| 00:00:01 |
    |   5 |      FAST DUAL                           |              |     1 |       |     2   (0)| 00:00:01 |
    |   6 |    TABLE ACCESS FULL                     | TG_FILE      |   565K|    12M|   659   (2)| 00:00:08 |
    |   7 |   TABLE ACCESS FULL                      | TG_FILE_DATA |   852K|   128M|  3863   (1)| 00:00:47 |
    Predicate Information (identified by operation id):
       1 - access("TF"."FILE_ID"="TFD"."FILE_ID" AND "TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
       2 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
    Statistics
              7  recursive calls
              0  db block gets
          16783  consistent gets
          16779  physical reads
              0  redo size
            916  bytes sent via SQL*Net to client
            524  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed Indexes are present in both the tables ( TG_FILE, TG_FILE_DATA ) on column FILE_ID.
    select
         index_name,blevel,leaf_blocks,DISTINCT_KEYS,clustering_factor,num_rows,sample_size
    from
         all_indexes
    where table_name in ('TG_FILE','TG_FILE_DATA');
    INDEX_NAME                     BLEVEL LEAF_BLOCKS DISTINCT_KEYS CLUSTERING_FACTOR     NUM_ROWS SAMPLE_SIZE
    TG_FILE_PK                          2        2160        552842             21401       552842      285428
    TG_FILE_DATA_PK                     2        3544        852297             61437       852297      852297 Ideally the view should have used NESTED LOOP, to use the indexes since the no. of rows coming from object collection is only 2.
    But it is taking default as 8168, leading to HASH join between the tables..leading to FULL TABLE access.
    So my question is, is there any way by which I can change the statistics while using collections in SQL ?
    I can use hints to use indexes but planning to avoid it as of now. Currently the time shown in explain plan is not accurate
    Modified query with hints :
    SELECT    
        /*+ index(tf TG_FILE_PK ) index(tfd TG_FILE_DATA_PK) */
        9999,
        tbl_typ.FILE_ID,
        tf.FILE_NM ,
        tf.MIME_TYPE ,
        dbms_lob.getlength(tfd.FILE_DATA)
    FROM
        TG_FILE tf,
        TG_FILE_DATA tfd,
            SELECT
            FROM
                TABLE
                        SELECT
                             CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                             OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
                        FROM
                             dual
        tbl_typ
    WHERE
        tf.FILE_ID     = tfd.FILE_ID
    AND tf.FILE_ID  = tbl_typ.FILE_ID
    AND tfd.FILE_ID = tbl_typ.FILE_ID;
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 1670128954
    | Id  | Operation                                 | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                          |                 |     1 |   194 | 29978   (1)| 00:06:00 |
    |   1 |  NESTED LOOPS                             |                 |       |       |            |          |
    |   2 |   NESTED LOOPS                            |                 |     1 |   194 | 29978   (1)| 00:06:00 |
    |   3 |    NESTED LOOPS                           |                 |  8168 |  1363K| 16379   (1)| 00:03:17 |
    |   4 |     VIEW                                  |                 |  8168 |   103K|    29   (0)| 00:00:01 |
    |   5 |      COLLECTION ITERATOR CONSTRUCTOR FETCH|                 |  8168 | 16336 |    29   (0)| 00:00:01 |
    |   6 |       FAST DUAL                           |                 |     1 |       |     2   (0)| 00:00:01 |
    |   7 |     TABLE ACCESS BY INDEX ROWID           | TG_FILE_DATA    |     1 |   158 |     2   (0)| 00:00:01 |
    |*  8 |      INDEX UNIQUE SCAN                    | TG_FILE_DATA_PK |     1 |       |     1   (0)| 00:00:01 |
    |*  9 |    INDEX UNIQUE SCAN                      | TG_FILE_PK      |     1 |       |     1   (0)| 00:00:01 |
    |  10 |   TABLE ACCESS BY INDEX ROWID             | TG_FILE         |     1 |    23 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       8 - access("TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
       9 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
           filter("TF"."FILE_ID"="TFD"."FILE_ID")
    Statistics
              0  recursive calls
              0  db block gets
             16  consistent gets
              8  physical reads
              0  redo size
            916  bytes sent via SQL*Net to client
            524  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed
    Thanks,
    B

    Thanks Tubby,
    While searching I had found out that we can use CARDINALITY hint to set statistics for TABLE funtion.
    But I preferred not to say, as it is currently undocumented hint. I now think I should have mentioned it while posting for the first time
    http://www.oracle-developer.net/display.php?id=427
    If we go across the document, it has mentioned in total 3 hints to set statistics :
    1) CARDINALITY (Undocumented)
    2) OPT_ESTIMATE ( Undocumented )
    3) DYNAMIC_SAMPLING ( Documented )
    4) Extensible Optimiser
    Tried it out with different hints and it is working as expected.
    i.e. cardinality and opt_estimate are taking the default set value
    But using dynamic_sampling hint provides the most correct estimate of the rows ( which is 2 in this particular case )
    With CARDINALITY hint
    SELECT
        /*+ cardinality( e, 5) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 1467416936
    | Id  | Operation                             | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                      |      |     5 |    10 |    29   (0)| 00:00:01 |
    |   1 |  COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     5 |    10 |    29   (0)| 00:00:01 |
    |   2 |   FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    With OPT_ESTIMATE hint
    SELECT
         /*+ opt_estimate(table, e, scale_rows=0.0006) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Execution Plan
    Plan hash value: 4043204977
    | Id  | Operation                              | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                       |      |     5 |   485 |    29   (0)| 00:00:01 |
    |   1 |  VIEW                                  |      |     5 |   485 |    29   (0)| 00:00:01 |
    |   2 |   COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     5 |    10 |    29   (0)| 00:00:01 |
    |   3 |    FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    With DYNAMIC_SAMPLING hint
    SELECT
        /*+ dynamic_sampling( e, 5) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 1467416936
    | Id  | Operation                             | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                      |      |     2 |     4 |    11   (0)| 00:00:01 |
    |   1 |  COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     2 |     4 |    11   (0)| 00:00:01 |
    |   2 |   FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    Note
       - dynamic sampling used for this statement (level=2)I will be testing the last option "Extensible Optimizer" and put my findings here .
    I hope oracle in future releases, improve the statistics gathering for collections which can be used in DML and not just use the default block size.
    By the way, are you aware why it uses the default block size ? Is it because it is the smallest granular unit which oracle provides ?
    Regards,
    B

  • How to declare a table type while executing a Procdure??

    Hi All,
    I'm facing a problem that i'm not able to call a type as an input to a proc.
    My proc has two inputs as table type and other normal inputs.
    I'm using these table type to insert value into another table.
    But when i try and execute the procedure in a DECLARE - BEGIN - END block, i'm not able to define the type properly.
    Please help mw put on this??
    Thnx in advance!!!

    Are you trying to create stored procedure with table type parameter? If so, you either needto declare table type in sql or in a PL/SQL package. For example:
    SQL> create or replace
      2    type tbl_type
      3    as table of number
      4  /
    Type created.
    SQL> create or replace
      2    procedure p1(
      3                 p_tbl tbl_type
      4                )
      5      is
      6      begin
      7          for i in 1..p_tbl.count loop
      8            dbms_output.put_line(p_tbl(i));
      9          end loop;
    10  end;
    11  /
    Procedure created.
    SQL> set serveroutput on
    SQL> begin
      2      p1(tbl_type(1,3,5,99));
      3  end;
      4  /
    1
    3
    5
    99
    PL/SQL procedure successfully completed.
    SQL> create or replace
      2    package pkg1
      3      is
      4        type tbl_type is table of number;
      5  end;
      6  /
    Package created.
    SQL> create or replace
      2    procedure p2(
      3                 p_tbl pkg1.tbl_type
      4                )
      5      is
      6      begin
      7          for i in 1..p_tbl.count loop
      8            dbms_output.put_line(p_tbl(i));
      9          end loop;
    10  end;
    11  /
    Procedure created.
    SQL> set serveroutput on
    SQL> begin
      2      p2(pkg1.tbl_type(1,3,5,99));
      3  end;
      4  /
    1
    3
    5
    99
    PL/SQL procedure successfully completed.
    SQL> SY.

  • How to write table name in SQL according to the user input

    hi
      i want to select data from a table , and the table name, field name is input by the user, for example, user input table name T1, field name F1 and i want to construct a SQL like select F1 into a_var from T1 . how does the SQL statement written? thanks for your advice.

    hi
    for ur requirement u should go for field sysmbols...
    dynamic internal tables..
    u can chk this....
    TYPE-POOLS : slis.
    PARAMETERS : p_struc LIKE dd02l-tabname.
    DATA : it_fieldcat TYPE lvc_t_fcat,
            t_output TYPE REF TO data .
    FIELD-SYMBOLS: <t_output> TYPE table ,
                   <wa_output> TYPE ANY,
                   <fval> TYPE ANY.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      I_BUFFER_ACTIVE              = I_BUFFER_ACTIVE
       i_structure_name             = p_struc
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           = I_BYPASSING_BUFFER
      I_INTERNAL_TABNAME           = I_INTERNAL_TABNAME
      CHANGING
        ct_fieldcat                  = it_fieldcat
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    IF sy-subrc <> 0.
    MESSAGE i000(bctrain) WITH 'MERGE FAILED'.
    *ELSE.
    MESSAGE i000(bctrain) WITH 'MERGE SUCCESS'.
    ENDIF.
    CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
    ASSIGN t_newline->* TO <fs_dyntable>.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
       I_STYLE_TABLE             =
        it_fieldcatalog           = it_fieldcat
       I_LENGTH_IN_BYTE          =
      IMPORTING
        ep_table                  = t_output
       E_STYLE_FNAME             =
      EXCEPTIONS
        generate_subpool_dir_full = 1
        OTHERS                    = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ASSIGN t_output->* TO <t_output>.
    SELECT * up to 10 rows FROM
       (p_struc)  INTO
       CORRESPONDING FIELDS OF
       TABLE <t_output>.
    *write : / 'dynamic table created'.
    LOOP AT <t_output> ASSIGNING  <wa_output>.
      DO.
        ASSIGN component sy-index of structure <wa_output> to <fval>.
        IF sy-subrc <> 0.
          WRITE : /.
          EXIT.
        ELSE.
          WRITE : <fval>.
        ENDIF.
      ENDDO.
    ENDLOOP.
    Message was edited by:
            Premalatha G

  • Sporadically getting error "string or binary data would be truncated" in SQL server 2008 while inserting in a Table Type object

    I am facing a strange SQL exception:-
    The code flow is like this:
    .Net 4.0 --> Entity Framework --> SQL 2008 ( StoredProc --> Function {Exception})
    In the SQL Table-Valued Function, I am selecting a column (nvarchar(50)) from an existing table and (after some filtration using inner joins and where clauses) inserting the values in a Table Type Object having a column (nvarchar(50))
    This flow was working fine in SQL 2008 but now all of sudden the Insert into @TableType is throwing  "string or binary data would be truncated"  exception. 
    Insert Into @ObjTableType
    Select * From dbo.Table
    The max length of data in the source column is 24 but even then the insert statement into nvarchar temp column is failing.
    Moreover, the same issue started coming up few weeks back and I was unable to find the root cause, but back then it started working properly after few hours
    (issue reported at 10 AM EST and was automatically resolved post 8 PM EST). No refresh activity was performed on the database.
    This time however the issue is still coming up (even after 2 days) but is not coming up in every scenario. The data set, for which the error is thrown, is valid and every value in the function is fetched from existing tables. 
    Due to its sporadic nature, I am unable to recreate it now :( , but still unable to determine why it started coming up or how can i prevent such things to happen again.
    It is difficult to even explain the weirdness of this bug but any help or guidance in finding the root cause will be very helpful.
    I also Tried by using nvarchar(max) in the table type object but it didn't work.
    Here is a code similar to the function which I am using:
    BEGIN
    TRAN
    DECLARE @PID
    int = 483
    DECLARE @retExcludables
    TABLE
        PID
    int NOT
    NULL,
        ENumber
    nvarchar(50)
    NOT NULL,
        CNumber
    nvarchar(50)
    NOT NULL,
        AId
    uniqueidentifier NOT
    NULL
    declare @PSCount int;
    select @PSCount =
    count('x')
    from tblProjSur ps
    where ps.PID
    = @PID;
    if (@PSCount = 0)
    begin
    return;
    end;
    declare @ExcludableTempValue table (
            PID
    int,
            ENumber
    nvarchar(max),
            CNumber
    nvarchar(max),
            AId
    uniqueidentifier,
            SIds
    int,
            SCSymb
    nvarchar(10),
            SurCSymb
    nvarchar(10)
    with SurCSymbs as (
    select ps.PID,
                   ps.SIds,              
                   csl.CSymb
    from tblProjSur ps
                right
    outer join tblProjSurCSymb pscs
    on pscs.tblProjSurId
    = ps.tblProjSurId
    inner join CSymbLookup csl
    on csl.CSymbId
    = pscs.CSymbId 
    where ps.PID
    = @PID
        AssignedValues
    as (
    select psr.PID,
                   psr.ENumber,
                   psr.CNumber,
                   psmd.MetaDataValue
    as ClaimSymbol,
                   psau.UserId
    as AId,
                   psus.SIds
    from PSRow psr
    inner join PSMetadata psmd
    on psmd.PSRowId
    = psr.SampleRowId
    inner join MetaDataLookup mdl
    on mdl.MetaDataId
    = psmd.MetaDataId
    inner join PSAUser psau
    on psau.PSRowId
    = psr.SampleRowId
                inner
    join PSUserSur psus
    on psus.SampleAssignedUserId
    = psau.ProjectSampleUserId
    where psr.PID
    = @PID
    and mdl.MetaDataCommonName
    = 'CorrectValue'
    and psus.SIds
    in (select
    distinct SIds from SurCSymbs)         
        FullDetails
    as (
    select asurv.PID,
    Convert(NVarchar(50),asurv.ENumber)
    as ENumber,
    Convert(NVarchar(50),asurv.CNumber)
    as CNumber,
                   asurv.AId,
                   asurv.SIds,
                   asurv.CSymb
    as SCSymb,
                   scs.CSymb
    as SurCSymb
    from AssignedValues asurv
    left outer
    join SurCSymbs scs
    on    scs.PID
    = asurv.PID
    and scs.SIds
    = asurv.SIds
    and scs.CSymb
    = asurv.CSymb
    --Error is thrown at this statement
    insert into @ExcludableTempValue
    select *
    from FullDetails;
    with SurHavingSym as (   
    select distinct est.PID,
                            est.ENumber,
                            est.CNumber,
                            est.AId
    from @ExcludableTempValue est
    where est.SurCSymb
    is not
    null
    delete @ExcludableTempValue
    from @ExcludableTempValue est
    inner join SurHavingSym shs
    on    shs.PID
    = est.PID
    and shs.ENumber
    = est.ENumber
    and shs.CNumber
    = est.CNumber
    and shs.AId
    = est.AId;
    insert @retExcludables(PID, ENumber, CNumber, AId)
    select distinct est.PID,
    Convert(nvarchar(50),est.ENumber)
    ENumber,
    Convert(nvarchar(50),est.CNumber)
    CNumber,
                            est.AId      
    from @ExcludableTempValue est 
    RETURN
    ROLLBACK
    TRAN
    I have tried by converting the columns and also validated the input data set for any white spaces or special characters.
    For the same input data, it was working fine till yesterday but suddenly it started throwing the exception.

    Remember, the CTE isn't executing the SQL exactly in the order you read it as a human (don't get too picky about that statement, it's at least partly true enough to say it's partly true), nor are the line numbers or error messages easy to read: a mismatch
    in any of the joins along the way leading up to your insert could be the cause too.  I would suggest posting the table definition/DDL for:
    - PSMetadata, in particular PSRowID, but just post it all
    - tblProjectSur, in particularcolumns CSymbID and TblProjSurSurID
    - cSymbLookup, in particular column CSymbID
    - PSRow, in particular columns SampleRowID, PID,
    - PSAuser and PSUserSur, in particualr all the USERID and RowID columns
    - SurCSymbs, in particular colum SIDs
    Also, a diagnostic query along these lines, repeat for each of your tables, each of the columns used in joins leading up to your insert:
    Select count(asurv.sid) as count all
    , count(case when asurv.sid between 0 and 9999999999 then 1 else null end) as ctIsaNumber
    from SurvCsymb
    The sporadic nature would imply that the optimizer usually chooses one path to the data, but sometimes others, and the fact that it occurs during the insert could be irrelevant, any of the preceding joins could be the cause, not the data targeted to be inserted.

  • How to retrieve the values from PL/SQL table types.

    Hi Every one,
    I have the following procedure:
    DECLARE
    TYPE t1 IS TABLE OF emp%ROWTYPE
    INDEX BY BINARY_INTEGER;
    t t1;
    BEGIN
    SELECT *
    BULK COLLECT INTO t
    FROM emp;
    END;
    This procedure works perfectly fine to store the rows of employee in a table type. I am not able to retrieve the values from Pl/SQL table and display it using dbms_output.put_line command.
    Can anybody help me please!!!!!
    Thanks
    Ahmed.

    You mean, you can't add this
    for i in t.first..t.last loop
    dbms_output.put_line(t(i).empno||' '||t(i).ename||' '||t(i).job);
    end loop;or you can't add this
    set serveroutput onor maybe, you are working in third party application where dbms_output is not applicable at all?
    You see, not able like very similar it is not working - both are too vague...
    Best regards
    Maxim

  • Passing parameters to PL/SQL table types

    Hi Everybody,
    I have one question about passing PL/SQL tables types and tabs as IN parameter in procedure.I am working in 11.2.0.2.0 environment. I am stuck on how to pass those values to procedure.Please find below more details:
    Table 1:
    CREATE TABLE ITEMS
    ITEM_ID VARCHAR2(40 BYTE) NOT NULL,
    ITEM_NAME VARCHAR2(40 BYTE),
    SERIAL NUMBER(2),
    ADDED_ON DATE);
    Table 2:
    CREATE TABLE ITEM_ACTIVITY_INFO
    ITEM_ID VARCHAR2(40 BYTE) NOT NULL,
    ACCOUNT_TYPE VARCHAR2(1 BYTE),
    ID_NUMBER NUMBER(3),
    ACTIVATION_DATE DATE);
    Table 3:
    CREATE TABLE ITEM_GROUP
    GROUP_ID NUMBER(2) NOT NULL,
    ITEM_ID VARCHAR2(40 BYTE),
    GROUP_TYPE VARCHAR2(20 BYTE),
    GROUP_DATE DATE);
    Table 4:
    CREATE TABLE ITEM_ADDRESS
    GROUP_ID NUMBER(2) NOT NULL,
    NAME VARCHAR2(60 BYTE),
    ADDRESS VARCHAR2(100));
    Following types are created:
    CREATE OR REPLACE TYPE ITEMS_TYPE AS OBJECT
    ITEM_ID VARCHAR2(40 BYTE),
    ITEM_NAME VARCHAR2(40 BYTE),
    SERIAL NUMBER(2),
    ADDED_ON DATE);
    CREATE OR REPLACE TYPE ITEM_ACTIVITY_TYPE AS OBJECT
    ITEM_ID VARCHAR2(40 BYTE),
    ACCOUNT_TYPE VARCHAR2(1 BYTE),
    ID_NUMBER NUMBER(3),
    ACTIVATION_DATE DATE);
    CREATE OR REPLACE TYPE ITEM_GROUP_COMP_TYPE AS OBJECT
    GROUP_ID NUMBER(2) NOT NULL,
    ITEM_ID VARCHAR2(40 BYTE),
    GROUP_TYPE VARCHAR2(20 BYTE),
    GROUP_DATE DATE
    ITEM_ADDRESS_IN ITEM_ADDRESS_TYPE);
    CREATE OR REPLACE TYPE ITEM_ADDRESS_TYPE AS OBJECT
    GROUP_ID NUMBER(2),
    NAME VARCHAR2(60 BYTE),
    ADDRESS VARCHAR2(100));
    CREATE OR REPLACE TYPE ITEM_GROUP_COMP_TAB AS TABLE OF ITEM_GROUP_COMP_TYPE;
    Create or replace procedure ITEM_ADD_CHANGE(
    ITEM_IN IN ITEMS_TYPE,
    ITEM_ACTIVITY_IN IN ITEM_ACTIVITY_TYPE,
    ITEM_GROUP_IN IN ITEM_GROUP_COMP_TAB,
    ITEM_OUT IN OUT ITEMS.ITEM_ID%TYPE);
    Above are the paramteres we are passing to procedure.
    I need help in how to pass parameters to above procedure. All comments and responses will be highly appreciated. Thanks everyone for going through the post. Please let me know if more more information is required on this problem.
    Regards
    Dev

    Billy  Verreynne  wrote:
    Types used in this fashion, only make sense if the table is based on the type. It makes very little sense to have a table structure and then to duplicate the structure using a type.
    The 2 structures may be defined the same. But they are NOT interchangeable and requires one to be converted to the other to use. This is not sensible in my view. It is far easier in that case to simply use the PL/SQL macro +%RowType+ to create a duplicate structure definition - one that can natively be used for touching that table, without conversions required.
    If you do want to use types, define the type, then define the table of that type, adding the required constraints (pk, fk, not null, check) to the table's definition.Billy:
    Just curious, why do you say it makes very little sense to have a type modeled on a table? I do that a lot. In my case, I am getting the values from an external program, not building them manually, but it makes a lot of sense to me.
    One application where I do this a lot has a java front-end that parses HL7 messages. Each message contains at least minimal information about a variable number of entities (and often several rows for an entity) in the database, and must be processed as a single atomic trasnaction. So, rather than have potentially hundreds of parameters to the "main" driver procedures for different message types I created a set of types more or less identical to the tables representing the entities. The java program parses the mesasge and populates the type, then calls the appropriate stored procedure for the message type passing in the populated types. My stored procedure then does inserts/updates or deletes as appropriate over potentially dozens of tables.
    John

  • How to pass table type variable into function from SQL*PLUS ?

    How to pass a table type variable from sql*plus prompt into a function ?
    Thanx in advance.

    Krishna,
    Do you mean like this?SQL> DECLARE
      2      TYPE t_tbl IS TABLE OF VARCHAR2(20);
      3      l_sample_tbl           t_tbl;
      4
      5      FUNCTION print_contents ( p_tbl IN t_tbl )
      6      RETURN VARCHAR2
      7      IS
      8          l_string            VARCHAR2(1000);
      9      BEGIN
    10          FOR i IN 1..p_tbl.COUNT LOOP
    11              IF (i = 1) THEN
    12                  l_string := p_tbl(i);
    13              ELSE
    14                  l_string := l_string || ', ' || p_tbl(i);
    15              END IF;
    16          END LOOP;
    17          RETURN (l_string);
    18      END print_contents;
    19
    20  BEGIN
    21      l_sample_tbl := t_tbl();
    22      l_sample_tbl.EXTEND;
    23      l_sample_tbl(1) := 'one';
    24      l_sample_tbl.EXTEND;
    25      l_sample_tbl(2) := 'two';
    26      l_sample_tbl.EXTEND;
    27      l_sample_tbl(3) := 'three';
    28      l_sample_tbl.EXTEND;
    29      l_sample_tbl(4) := 'four';
    30      l_sample_tbl.EXTEND;
    31      l_sample_tbl(5) := 'five';
    32      DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
    33  END;
    34  /
    one, two, three, four, five
    PL/SQL procedure successfully completed.
    SQL> HTH,
    T.

  • PL/SQL table type in Forms 4.5

    Hi
    I am trying to use a pl/sql table type variable in Oracle forms 4.5 . I am able to compile this and run it on the database that the application connects to but in forms , it gives me a compilation error.
    Is there some restriction on using this datatype in forms 4.5
    Following is the syntax I am using:
    TYPE block_list_type IS TABLE of VARCHAR2(200) INDEX BY BINARY_INTEGER;
    block_list block_list_type;
    I get fatal syntax error even though the syntax is correct(checked it on the database).
    please let me know if I am doing something wrong.
    thanks a lot

    That explains it!!
    Thanks. My company is on oracle 10.7 and is too reluctant to move to higher versions. They finally bought I2 and are developing their own custom java applications and will phase out 10.7 but are not willing to move to the next version of Oracle !!
    Seems like they are done with Oracle .
    thanks for the input anyways.

  • Passing PL/SQL table type as IN Parameter to DB Adapter

    Hi,
    I have an requirement to pass multiple record values(array of values) to an API from BPEL process.
    For this,
    1) I have created a package procedure having PL/SQL table type variable as IN Parameter.
    2) In the BPEL process, created a DB adpater pointing to the above API.(Created wrapper API impicitly)
    When I intiated the BPEL process passing multiple values, the API is taking only the first value, ignoring rest of the values.
    Any reason, why only the first value is accepted by the API ?
    Thanks,
    Rapp.

    If I understand correctly, JPublisher generates a wrapper API for an underlying API that takes a PL/SQL table as an IN parameter. The wrapper will generate and use a SQL nested table as the type for the IN parameter of the wrapper procedure.
    The DB adapter DOES support nested tables, varrays, and objects as IN parameters of an API. The problem you are seeing is most likely due to the way you are modeling your BPEL process, specifically with respect to your Assign activities.
    When you Assign TO an IN parameter, make sure that you drill down all the way and choose the parameter name in the InputParameters root element. Similarly, when you Assign FROM the API value, you must drill down and choose the name of the OUT parameter in the OutputParameters root element.
    In a Transform activity, you would use the FOR construct on the target side to get the values of the nested table or varray from the source side.

  • User-Defined Table Types - Where is it in SQL Server 2008?

    I am having 2 issues:
    1.  I don't see a folder for 'User-Defined Table Types' under programmability-->Types
    2.  When I execute the following code to create a Type; I get an error 'Incorrect syntax near the keyword 'AS'.'
    USE Locations;
    GO
    /* Create a user-defined table type */
    CREATE TYPE LocationTableType AS TABLE
    ( LocationName VARCHAR(50)
    , CostRate INT );
    GO

    Hi Shayann,
    The  user-defined table type is a new
    feature from SQL Server 2008. If you want to use it you have to upgrade your database to SQL Server 2008 or above.
    In you scenario(SQL Server 2005),as a workaround, you can use the  local temporary table instead. 
    --in SQL Server 2005
    CREATE TABLE tblType(id INT,name VARCHAR(99))
    GO
    CREATE PROC proc1
    AS
    BEGIN
    SELECT * FROM #temp;
    END
    GO
    SELECT * INTO #temp FROM tblType; -- the #temp name is fixed
    INSERT INTO #temp VALUES(1,'Eric');
    EXEC proc1
    --In SQL Server 2008 or above
    CREATE TYPE LocationTableType AS TABLE
    ( id INT,
    name VARCHAR(99) );
    GO
    CREATE PROC proc1 @t LocationTableType READONLY
    AS
    BEGIN
    SELECT * FROM @t
    END
    GO
    DECLARE @t LocationTableType;
    INSERT INTO @t VALUES(1,'Eric');
    EXEC proc1 @t
    I still suggest you upgrade to higher SQL Server.
    If you have any question, feel free to let me know.
    Best regards,
    Eric

  • Is there table type object in PL/SQL?

    Hi.
    What I'm trying to do is, according to the some conditions, aggregate data as an object type( I am not sure that there's a similar thing)
    There are 5-6 conditions. then at last join those table type object.
    FYI, Here is an example
    Company will give bonus to a person who meet these conditions
    1. Salary is less than 1000$ - salary table
    2. More than 5 persons in his family - staff table
    3. gross sale is over 10000$
    In PL/SQL Package, I'll get those data as an object type and join those object just like in-line query.
    select emp_no
    from sal_tbl , staff_tbl, sale_tbl
    where sal_tbl = staff_tbl
    and sal_tbl = sale_tbl
    In my opinion I can get employee list who get bonus. because they meet all conditions.
    Reason why bonus condition will be updated continuously. I want to make them easy to maintanence. what if I need to add new conditions. Just add a new procedure that calculate new result and pass as an table type object.
    select emp_no
    from sal_tbl , staff_tbl, sale_tbl, new_tbl*
    where sal_tbl = staff_tbl
    and sal_tbl = sale_tbl
    and sal_tbl = new_tbl*
    Is there any thing just like what I think?
    Thanks in advance
    Message was edited by: me
    allbory
    I have read Oracle user guide - Collection, Record, and Cursor. But I can't get anything that I want.
    Give me some clues

    > In PL/SQL Package, I'll get those data as an object type and join those object just like
    in-line query.
    Not the best of ideas. If I'm getting what you're saying, you want to use the following approach:
    SQL> create or replace type TStrings as table of varchar2(4000);
    2 /
    Type created.
    SQL>
    SQL>
    SQL> create or replace procedure BadIdea( collection TStrings ) is
    2 minVal string(4000);
    3 maxVal string(4000);
    4 begin
    5 -- in the procedure we now run SQLs against the collection
    6 select
    7 MIN( column_value ) into minVal
    8 from TABLE( collection );
    9
    10 select
    11 MAX( column_value ) into maxVal
    12 from TABLE( collection );
    13 end;
    14 /
    Procedure created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> -- and then we call this procedure to do our "SQL" processing for us
    SQL> declare
    2 list TStrings;
    3 begin
    4 select
    5 object_name bulk collect into list
    6 from user_objects;
    7
    8 BadIdea( list );
    9 end;
    10 /
    PL/SQL procedure successfully completed.A collection of objects resides in (non-sharable and expensive) PL/SQL memory. Running SQL, requires the PL/SQL engine copying the data to the SQL engine into a structure and format that the SQL engine will understand.
    This is slow. This is expensive. This does not scale.
    It makes little sense to copy data from the very fast and hot and good and scalable db buffer cache into an expensive memory structure in the PGA and then run SQLs against that.
    > Reason why bonus condition will be updated continuously. I want to make them easy
    to maintanence. what if I need to add new conditions. Just add a new procedure that
    calculate new result and pass as an table type object.
    The way I read your SQL, your new_tbl* requires dynamic SQL. Which means you also need to dynamically cater for the correct column names to join on, to filter on, and to select from.
    Also not the best of ideas. Dynamic SQL like that requires a lot of code to deal correctly with bind variables. Lot of exception handling as there can easily be run-time errors as the code itself that is executed in turn creates new dynamic code to execute.
    If this is to be truly dynamic, then one approach would be that each rule needs to be executable as a SQL or PL/SQL block. Each rule needs to have an input like an employee number. Each rule needs to returns a boolean like value, saying whether the rule has passed or failed.
    Only when all the rules have been passed, can the bonus be allocated.
    This will deal fine with the "dynamic rule" requirement. Performance wise and scalability wise.. it may not be the best of ideas. 10 dynamic and very slow and expensive rules, could very well be rewritten as a one very fast and very cheap static SQL statement.
    Anyway, the dynamic rule approach can look something like the following:
    SQL> create or replace type TBonusRule is object
    2 (
    3 result# char(1),
    4 member function Passed return boolean
    5 )
    6 not final;
    7 /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create or replace type body TBonusRule is
    2 member function Passed return boolean is
    3 begin
    4 return( UPPER(self.result#) = 'Y' );
    5 end;
    6 end;
    7 /
    Type body created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create or replace type TBonusSQLRule under TBonusRule
    2 (
    3 constructor function TBonusSQLRule( empNo number, sqlStatement varchar2 ) return self as result
    4 ) final;
    5 /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create or replace type body TBonusSQLRule is
    2 constructor function TBonusSQLRule( empNo number, sqlStatement varchar2 ) return self as result is
    3 begin
    4 execute immediate sqlStatement
    5 into self.result#
    6 using IN empNo;
    7
    8 return;
    9 end;
    10
    11 end;
    12 /
    Type body created.
    SQL> show errors
    No errors.
    SQL>
    SQL> set serveroutput on
    SQL> declare
    2 rule1 TBonusSQLRule;
    3 rule2 TBonusSQLRule;
    4 empNo number;
    5 begin
    6 empNo := 7369; -- we process employee 7369
    7
    8 -- we apply bonus rule 1 that check if the employee is a clerk (of course,
    9 -- we could be reading these rules from a rules table - this example simply
    10 -- creates them dynamically)
    11 rule1 := new TBonusSQLRule( empNo, 'select ''Y'' from emp where empno = :0 and job=''CLERK''' );
    12
    13 if rule1.Passed then
    14 DBMS_OUTPUT.put_line( 'Rule 1. PASSED' );
    15 else
    16 DBMS_OUTPUT.put_line( 'Rule 1. FAILED' );
    17 end if;
    18
    19 -- rule 2 can for example check if the employee has been working for at least 5 years for the
    20 -- company
    21 rule2 := new TBonusSQLRule( empNo, 'select ''Y'' from emp where empno = :0 and (SYSDATE-hiredate)>5*365' );
    22
    23 if rule2.Passed then
    24 DBMS_OUTPUT.put_line( 'Rule 2. PASSED' );
    25 else
    26 DBMS_OUTPUT.put_line( 'Rule 2. FAILED' );
    27 end if;
    28
    29 end;
    30 /
    Rule 1. PASSED
    Rule 2. PASSED
    PL/SQL procedure successfully completed.
    SQL>
    PL/SQL rules can in a similar fashion be subclassed from the base/asbtract class. And rules can be persisted in a table too.
    But even though I did this example to illustrate just how flexible Oracle can be, I would personally think hard before using the above approach myself.
    Why?
    Because rules 1 and 2 resulted in two SQLs being fired. A single SQL could have done the job.
    2 SQLs were used for a single employee. I can use a single SQL to find ALL employees that matches the rule criteria.
    So... not very scalable and not very fast.

  • ODSI support for return type "PL/SQL TABLE"?

    Hello!
    We are trying to connect our ODSI to an Oracle function with return type "PL/SQL TABLE". The ODSI "wizard" (used to create the physical data service) seems to understand the interface during creation, but when executed it fails. The ODSI server complains about wrong type (PLS-00382: expression is of wrong type) when we execute it from the "test tab".
    The function's metadata is looks like this:
    <params xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes" xmlns:pn1="ld:physical/rekondis/CALC_DEBITING" >
    <param name="RETURN_VALUE" kind="return" xqueryType="pn1:RETURN_VALUE_ROW" nativeTypeCode="1111" nativeType="PL/SQL TABLE"/>
    <param name="PIN_CASE_ID" kind="in" xqueryType="xs:decimal" nativeTypeCode="3" nativeType="NUMBER"/>
    <param name="PIN_ACTION_CODE" kind="in" xqueryType="xs:decimal" nativeTypeCode="3" nativeType="NUMBER"/>
    <param name="PI_AD_NAME" kind="in" xqueryType="xs:string" nativeTypeCode="12" nativeType="VARCHAR2"/>
    </params>
    Any ideas how we can make this work!? Or is this not even supported in ODSI 10.3?
    Thanks!
    // Mikael

    Please refer to the documentation - http://download.oracle.com/docs/cd/E13162_01/odsi/docs10gr3/datasrvc/Create%20Physical%20Data%20Services%20from%20Stored%20Procedures.html

  • Retrieving PL/SQL Table Type returned by stored procedure using Java.

    Hi All,
    I am facing an issue in a Stored Procedure (SP) which returns Table Type, the PL/SQL complex type.
    Below mentioned is how my stored procedure looks like.
    CREATE OR REPLACE package sp_test_pkg as
    TYPE v_value_table_type is table of SW_VALID_CODE.swValue%Type
    index by binary_integer;
    v_swRMAStatus v_value_table_type;
    procedure sp_test
    (locale      in int,
              name      in SW_CODE.swName%Type,
              v_value_table out v_value_table_type,
    batch_size in int,
    out_batch_size in out int,
    status out int);
    end sp_test_lcode_code_pkg;
    My java program to access this stored procedure is as given below:
    import java.sql.*;
    import oracle.jdbc.driver.*;
    public class OracleTest {       
         public static void main(String args[]) {
         Connection con = null;
    OracleCallableStatement cstmt = null;
    String url = "url";
         String userName = "username";     
         String password = "password";
    try
              DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());     
              con = DriverManager.getConnection(url, userName, password);
         cstmt = (OracleCallableStatement)con.prepareCall("begin " +
              "sp_test_pkg.sp_test_pkg(?,?,?,?,?,?); end;");
              cstmt.setInt(1, 1);
         cstmt.setString(2, "Test");
              cstmt.registerOutParameter(3, OracleTypes.ARRAY);
              cstmt.setInt(4, 10);
              cstmt.setInt(5, 1);
              cstmt.registerOutParameter(5, Types.INTEGER);
              cstmt.registerOutParameter(6, Types.INTEGER);
              cstmt.execute();
    } catch(Exception ex) {
    ex.printStackTrace(System.err);
    } finally {
    if(cstmt != null) try{cstmt.close();}catch(Exception _ex){}
    if(con != null) try{con.close();}catch(Exception _ex){}
    When i execute this java program, i get the following error:
    java.sql.SQLException: Parameter Type Conflict: sqlType=2003
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:245)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:389)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:452)
         at OracleTest.main(OracleTest.java:49)
    I am not sure where i am going wrong. I have never worked on such complex types before. I want to retrieve the complex table type returned by the stored procedure using my java source code.
    Can anyone please help me out in resolving this issue?. This is very urgent.

    JDBC does not recognise types declared in PL/SQL. This is documented in the Dev Guide. [Find out more|http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraarr.htm#1057625].
    The only work around would be to build a wrapper which calls your existing PL/SQL procedures and returns a SQL type instead. Obviously not knowing your precise scenario I have no idea how much work this entails for you. It may be worth building a code generator.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

Maybe you are looking for

  • How to use a session variable in Conditional Format?

    Hi Gurus, I created a session variable , called Actual_date, using the following SELECT: SELECT SYSDATE FROM DUAL In a report title the following expression worked fine: @{biServer.variables['NQ_SESSION.Actual_date']} I red in a reply in this forum,

  • Fileshare between my Mac Pro Quad Core Intel Xeon (64-bit) & Power Mac 9600

    I want to make my Power Macintosh 9600/233 (Mac OS 9) a shared computer with my Mac Pro Quad Core Intel Xeon (64-bit)(Mac OS 10.6.6). I am using a Netopia Model 3346N-VGx DSL Ethernet Managed Switch to network with my Samsung printer and the Mac Book

  • Mapping of XML attributes with XML elements in Mediator Transformations

    Hi, The soure XML look like as below in the source directory of file adapter/read: <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- Edited by Oracle JDeveloper 11.1.1.1.3® --> <CATALOG> <PLANT COMMON="Bloodroot" BOTANICAL="Sanguinaria canadensis"> <

  • ITunesMiniPlayer.Resources error

    When I try to open iTunes I get the following error: "iTunesMiniPlayer.Resources is not a valid short file name" I downloaded 7.3 onto my WD passport drive (where I kept my old version of iTunes) and it worked fine after the download, but the first t

  • How to rename usb n to eth n

    Short version: With udev set to use 'old-style' network card naming (eth0, eth1, wlan0, ...), how do you change cards that init as 'usb<n>' to 'eth<n>'? Long version: I have a new laptop on the way that doesn't have a wired ethernet card.  However, t