Using arrary associative as parameter and passing then to the place where the clause of the select statement

Hello

I have this scenario where I have to pass multiple values to a parameter of a procedure of monkey and then collect in another variable (the lines can be multiple).

The parameter must be used in the where clause of the statement select here I create a sample table for the problem.

Create table test_tab (number of trans_id, cmts varchar2 (50));

insert into test_tab values (568890112115, ' wnlb-CMTS-11-04' ");

insert into test_tab values (568890112115, ' wnlb-CMTS-11-04' ");

insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

insert into test_tab values (568890112115, ' wnlb-CMTS-11-01' ");

insert into test_tab values (568890112115, ' wnlb-CMTS-12-02' ");

insert into test_tab values (568890112115, ' wnlb-CMTS-12-02' ");

This is so all cmts have same trans_id but different name

This query gives the result as -

Select the cmts, count (1)

of test_tab

where cmts ("wnlb-cmts-11-04','wnlb-cmts-11-01", "wnlb-CMTS-11-02'")

and trans_id = 568890112115

Cmts group;

COUNTY OF CMTS

WNLB-CMTS-11-04 2

3 WNLB-CMTS-11-01

Now, I want to use this query in a PLSQL block like where I can spend the CMTS collection and trans_id as a scalar variable and once again an OUTPUT parameter that holds the result of the query.

I use OUT parameter because it will be called to the JAVA program.

Here, I write a PACKAGE for it but it gives me compilation error!

create or replace package CMTS_SUCCESS_FAILED_API

is

type t_item_name is table of index varchar2 (50) by pls_integer;

TYPE t_cmts_count () IS RENDERING

CMTS VARCHAR2 (30),

number of NUMBER

);

type t_reseg_dtl is table of index t_cmts_count by pls_integer;

procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl);

end CMTS_SUCCESS_FAILED_API;

/

Now that I have created a different PACKAGE BODY, but none don't work!

1.

create or replace package CMTS_SUCCESS_FAILED_API

is

type t_item_name is table of index varchar2 (50) by pls_integer;

TYPE t_cmts_count () IS RENDERING

CMTS VARCHAR2 (30),

number of NUMBER

);

type t_reseg_dtl is table of index t_cmts_count by pls_integer;

procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl);

end;

/

create or replace package CMTS_SUCCESS_FAILED_API body

is

procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl)

is

Start

I'm in p_item_name.first... p_item_name. Last

loop

Select the cmts, count (1)

bulk collect into p_reseg_dtl (i)

of test_tab

where cmts = p_item_name (i)

and trans_id = p_trans_id

Cmts group;

end loop;

for r in p_reseg_dtl.first... p_reseg_dtl. Last

loop

dbms_output.put_line (p_reseg_dtl (r). TRANSACTION_ID | » '|| p_reseg_dtl (r). JOB_STATUS | » '|| p_reseg_dtl (r). CMTS);

end loop;

end CMTS_SUCCESS_FAILED_RESEG_ORDR;

end CMTS_SUCCESS_FAILED_API;

While I run this procedure it is said TOO_MANY LINES.

2.

create or replace package CMTS_SUCCESS_FAILED_API body

is

procedure CMTS_SUCCESS_FAILED_RESEG_ORDR (p_item_name t_item_name, p_trans_id in numbers, p_reseg_dtl to t_reseg_dtl)

is

cursor c_dtl is

Select the cmts, count (1)

of test_tab

where cmts = p_item_name < < error

and trans_id = p_trans_id

Cmts group;

Start

Open c_dtl;

collect the fetch c_dtl in bulk in p_reseg_dtl;

close c_dtl;

-for i in p_item_name.first... p_item_name. Last

-loop

-end loop;

end;

end;

THIS error GIVES BODY as EXPRESSION IS OF TYPE INCORRECT for where clause where I mark it as "BOLD".

I think Miss me a small detail to add here, but I can't do even now it seems for me that I'm working on it since the morning and SQL are a little complex in real time who also write.


I use-

Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

Please suggest me!

Until then I'm also working on this issue hope will find a solution.

In the database (we show it with a standalone function, you should put it in a package):

create or replace function CMTS_SUCCESS_FAILED_RESEG_ORDR (
  p_item_name IN SYS.DBMS_DEBUG_VC2COLL,
  p_trans_id IN number
)
return sys_refcursor is
  l_refcur sys_refcursor;
begin
  open l_refcur for
    SELECT cmts , COUNT(*)
      FROM test_tab
    WHERE cmts member of p_item_name
       AND trans_id = p_trans_id
    GROUP BY cmts;
  return l_refcur;
end CMTS_SUCCESS_FAILED_RESEG_ORDR;
/

In Java:

import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleTypes;
import oracle.jdbc.pool.OracleDataSource;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

public class SQLCollection {

    public static void main(String[] args) throws SQLException {

        System.out.println("Class SQLCollection started.");

        OracleDataSource ods = null;
        Connection conn = null;
        CallableStatement cs = null;
        ResultSet rset = null;

        try {
            ods = new OracleDataSource();
            String url = "jdbc:oracle:thin:@//127.0.0.1:1522/orcl.localdomain";
            ods.setURL(url);
            ods.setUser("stew");
            ods.setPassword("stew");
            conn = ods.getConnection();
            conn.setAutoCommit(false);

            ArrayDescriptor oracleVarchar2Collection =
                ArrayDescriptor.createDescriptor("SYS.DBMS_DEBUG_VC2COLL", conn);
            String[] inset = new String[2];
            inset[0] = "wnlb-cmts-11-04";
            inset[1] = "wnlb-cmts-11-01";
            ARRAY ora_inset = new ARRAY(oracleVarchar2Collection, conn, inset);

            cs = conn.prepareCall("begin ? := CMTS_SUCCESS_FAILED_RESEG_ORDR(?, ?); end;");
            cs.registerOutParameter(1, OracleTypes.CURSOR);
            cs.setArray(2, ora_inset);
            cs.setBigDecimal(3, new BigDecimal("568890112115"));
            cs.execute();

            // Dump the cursor
            rset = ((OracleCallableStatement)cs).getCursor(1);
            while (rset.next())
                System.out.println(rset.getString(1) + ": " + rset.getInt(2));

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (rset != null) {
                rset.close();
            }
            if (cs != null) {
                cs.close();
            }
            if (conn != null) {
                conn.close();
            }
            System.out.println("Class SQLCollection ended.");
        }
    }
}

Tags: Database

Similar Questions

  • How to pass parameter in the function using the select statement?

    Hello

    I had a problem. I can't pass as parameter to the function by using the select statement. But it can pass as a parameter using the "code". How can I solve this problem?

    For example,.
    Select * from table (SplitFunction ('HS750020, HS750021')) < < < this work.

    but

    Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) < < < do not work.

    Thank you for trying to help him. Thank you.

    Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36'))< do="" not="">

    Try like this

    select * from table(select splitfunction(lot_no) from tracer_search_schedule where job_id='36')
    

    Just make sure that your subquery returns only 1 row.

  • In Windows XP, I could choose a file (or files), then go to Edit, and then invert the selection. How do I do that in Windows 7?

    Original title: invert the selection

    In Windows XP, I could choose a file (or files), then go to Edit, and then invert the selection.  How do I do that in Windows 7?

    I think Alt-E-I is also the shortcut for this feature.

  • When I make a selection using the lasso and try to copy the selection, nothing is copied.  Why?

    I have PhotoShop CS6 for Mac, version 13.0.6.  When I make a selection using the lasso (or any other selection tool) and select 'Copy' and try to move the selection copied, nothing is copied.  What is going on?  I can't find an answer in my search for Abobe PS or the Web site, in general.

    If you still use the selection tools when you try to move the contents of a selection, it will simply move the selection. If you want to move the content, use the tool move (but be aware that the default action is to cut; use Opt (Alt on Windows) to copy the selection by dragging).

  • can I use photoshop on a pc and a mac with the same license?

    can I use photoshop on a pc and a mac with the same license?

    Yes, just install the application of cc, https://creative.adobe.com/products/creative-cloud on each computer desktop and use it to install your programs cc.

  • I used an effects after trial and now I bought, the need to install anything new?

    I used an effects after trial and now I bought, the need to install anything new?

    There is no need of a reinstall of the application. To activate the subscription, please sign out and sign back for the CC desktop application. For more information, see connect and disconnect activate Cloud Creative applications

    Hope this will help you.

    Kind regards

    Hervé Khare

  • I got Pro 8.0 on an old computer.  tried to install pto 8.1 using only series. as old and it did not work.  where can I find pro 8.0 or where can I find the correct SN?

    I got Pro 8.0 on an old computer.  tried to install pto 8.1 using only series. as old and it did not work.  where can I find pro 8.0 or where can I find the correct SN?

    If you do not need acrobat 8 pro or something another link below, you will need to explain.


    Available downloadable Setup files:

    Download and installation help links Adobe

    Download and installation to Prodesigntools help links are located on the most linked pages.  They are essential; especially steps 1, 2 and 3.  If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions". window using the Lightroom 3 link to see these "important Instructions".

  • How to split string separated by commas and pass to the clause of the select statement

    Referring to article How to divide string separated by commas, then pass to clause of a select statement, tquery that there the following plan:

    Query1:

    select * from emp where ename in (
        select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual
        connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null );
    

    Base1:

    Plan hash value: 4242290184
    
    
    --------------------------------------------------------------------------------------------
    | Id  | Operation                       | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                |          |     1 |   133 |     7  (29)| 00:00:01 |
    |*  1 |  HASH JOIN                      |          |     1 |   133 |     7  (29)| 00:00:01 |
    |   2 |   VIEW                          | VW_NSO_1 |     1 |    46 |     3  (34)| 00:00:01 |
    |   3 |    HASH UNIQUE                  |          |     1 |       |     3  (34)| 00:00:01 |
    |*  4 |     CONNECT BY WITHOUT FILTERING|          |       |       |            |          |
    |   5 |      FAST DUAL                  |          |     1 |       |     2   (0)| 00:00:01 |
    |   6 |   TABLE ACCESS FULL             | EMP      |    14 |  1218 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - access("ENAME"="$nso_col_1")
       4 - filter( REGEXP_SUBSTR ('SMITH,ALLEN,WARD,JONES','[^,]+',1,LEVEL) IS NOT NULL)
    

    However, the following query generates the plan I want:

    Query2:

    select * from emp where ename in ('SMITH','ALLEN','WARD','JONES');
    

    Plan2:

    Plan hash value: 3956160932
    
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     4 |   348 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     4 |   348 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - filter("ENAME"='ALLEN' OR "ENAME"='JONES' OR "ENAME"='SMITH' OR
                  "ENAME"='WARD')
    

    Can I change the query1 query for plan2?

    As Juliet was mentioned in the first SQL that you generate from the ENAME list that you must pass in the IN clause when executing. But in the second SQL, it passed as a static value. So first SQL must do more work. So you see a different execution plan.

    But this is a work around to get what you are looking for. But I can't say it's a foolproof method. But anyway here you go.

    SQL > var ename_list varchar2 (100)
    SQL > exec: ename_list: = 'SMITH, ALLEN, WARD, JONES ';

    PL/SQL procedure successfully completed.

    SQL > select *.
    2 of PEM
    where the 3 «,» | : ename_list | ',' like '%', | Ename | ',%';

    EMPNO, ENAME, JOB HIREDATE DEPTNO ID COM SAL MGR
    ---------- ------ --------- ---------- --------- ---------- ---------- ---------- ----------
    7369 SMITH COMMITTED 7902 2975 2 APRIL 81 0 20
    7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
    7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
    7566 JONES MANAGER 7839 2975 2 APRIL 81 0 20

    SQL > select * from table (dbms_xplan.display_cursor);

    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------------------------------
    SQL_ID, 848zhvbvgf7d6, number of children 0
    -------------------------------------
    Select * from emp where «,» | : ename_list | ',' like '%', | Ename
    || ',%'

    Hash value of plan: 2872589290

    --------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      |       |       |     2 (100) |          |
    |*  1 |  TABLE ACCESS FULL | EMP |     1.    38.     2 (0) | 00:00:01 |
    --------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 - filter(','||:ENAME_LIST||',' LIKE '%,'||") ENAME "|", %')

    19 selected lines.

    SQL >

  • SHOW_LOV need to pass a parameter for the select statement

    Hello

    I have a requirement that there is only a drop down list but the display of the list should be based on the certern parameter.

    I have a table (id, type, description). The select statement for dropdown I need is

    SELECT id, description of the table where type = & input_param.

    Can someone help please!

    create a field and create value in the list select id, description from table1 where col =: block1.item

  • Pass variable in the SELECT... WHERE... (&lt; VAR &gt;) have problems.

    Hi all

    I'm using Oracle 11 g R2 and Linux.

    I'm working on a code in which I need to dynamically pass values to 'IN' clause in a select statement.

    A short demonstration of my question is as below: -.

    Set serveroutput on

    /

    declare

    NUM varchar2 (100): = 1, 2';

    number of v_inst_id;


    Start


    dbms_output.put_line (' value of num before :-'||) (NB);

    Select INST_ID select

    in v_inst_id

    GV $ session

    where username = 'SYS '.

    and to_char (inst_id) in (num) - 1, 2

    order of INST_ID select;


    exception

    while others then

    dbms_output.put_line (SQLERRM);


    end;

    /

    anonymous block filled

    Before value of num:-1, 2

    ORA-01403: no data found

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Select INST_ID select

    -by v_inst_id

    GV $ session

    where username = 'SYS '.

    and to_char (inst_id) in (1,2)

    order of INST_ID select;

    INST_ID SELECT

    ----------

    1

    1

    1

    2

    2

    2


    Please let me know why my request does not work in plsql but works perfectly in sql.


    Thanks in advance.

    VJ4 wrote:

    Hello

    Thanks for your reply.

    Can you please give a brief explanation on the example you showed?

    with this request

    SELECT to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) p_id

    OF THE DOUBLE

    WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

    CONNECTION BY INSTR (num, ',', 1, LEVEL - 1) > 0

    I shared your (digital) channel of n number of rows in the table

    SQL > set serveroutput on;

    SQL >

    SQL >-created the 11.06.2014 by RAMIN. H

    SQL > declare

    2 num varchar2 (100): = '1.2'.

    3. start

    4 r in (SELECT to_number (REGEXP_SUBSTR (num, ' [^,] +', 1, ROWNUM)) p_id)

    5 DOUBLE

    6. WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

    7 CONNECT BY INSTR (num, ',', 1, LEVEL - 1) > 0) loop

    8 dbms_output.put_line (r.p_id);

    9 end of the loop;

    10 end;

    11.

    1

    2

    PL/SQL procedure successfully completed

    SQL >

    SQL >-created the 11.06.2014 by RAMIN. H

    SQL > declare

    2 num varchar2 (100): = "1,2,3,4,5,6";

    3. start

    4 r in (SELECT to_number (REGEXP_SUBSTR (num, ' [^,] +', 1, ROWNUM)) p_id)

    5 DOUBLE

    6. WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

    7 CONNECT BY INSTR (num, ',', 1, LEVEL - 1) > 0) loop

    8 dbms_output.put_line (r.p_id);

    9 end of the loop;

    10 end;

    11.

    1

    2

    3

    4

    5

    6

    PL/SQL procedure successfully completed

    SQL >

    SQL >

    SQL > SELECT to_number (REGEXP_SUBSTR ('& num', ' [^,] +', 1, ROWNUM)) p_id

    2 FROM TWO

    3. WHERE to_number (REGEXP_SUBSTR ('& num', ' [^,] +', 1, ROWNUM)) IS NOT NULL

    4 CONNECT BY INSTR ("& num', ',', 1, LEVEL - 1") > 0

    5.

    P_ID

    ----------

    1

    2

    3

    4

    5

    6

    SQL >

    ----

    Ramin Hashimzade

  • Why I can't use the procedure in the select statement

    Why I can't use the procedure in the select statement

    And you may not usa a SQL function if it has out parameters

    SQL> create function myfun(p1 in out number) return number is
      2  begin
      3  p1:=1;
      4  return 2;
      5  end;
      6  /
    
    SQL> select myfun(5) from dual;
    select myfun(5) from dual
           *
    ERRORE alla riga 1:
    ORA-06572: Function MYFUN has out arguments
    

    In fact, the problem is that an output parameter is passed 'ref' and not 'val '...

    Max

  • passing multiple values from the query in the select statement of the procedure

    I am collecting IDS to select education agreement from the date of rental values and then I would pass the result of the query in the statement select to get the result.
    data type for the contract id is of type varchar and date of rental there is more than one id to contract for most of the time. Help, please. Thank you

    CREATE OR REPLACE PROCEDURE abstract_menu (p_letting   IN     VARCHAR2,
                                               p_results      OUT SYS_REFCURSOR)
    IS
       v_contractId   VARCHAR2 (40);
    
    SELECT lcontid
      INTO v_contractId
      FROM letprop
     WHERE datestat IS NOT NULL AND letting = p_letting AND letstat <> 'R';
    
    
    BEGIN
       OPEN p_results FOR
            SELECT DISTINCT
                      SUBSTR (l.letting, 3, 2)
                   || '-'
                   || SUBSTR (l.letting, 5, 2)
                   || '-'
                   || SUBSTR (l.letting, 1, 2)
                      lettingdate,
                   l.lcontid contractid,
                   SUBSTR (q.cprojnum, 1, 10) projectnumber,
                   DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route)))
                      routenumber,
                   L.DATESTAT statusdate,
                   L.LETSTAT lettingstatus,
                   (q.cdescr) jobdescription,
                   INITCAP (q.clocat1 || q.clocat2) LOCATION
              FROM vendor v,
                   vendaddr r,
                   letprop l,
                   planhold p,
                   proposal q,
                   project j,
                   propproj k,
                   bidlet bd
             WHERE     v.vendor = r.vendor
                   AND k.contid = q.contid
                   AND k.pcn = j.pcn
                   AND l.lcontid = k.contid
                   AND p.vendor = v.vendor
                   AND l.letting = p.letting
                   AND l.lcontid IN v_contactid  "**************This is where I would like to pass the contract id from the above select statement***********'"
                   AND l.CALL = p.CALL
                   AND r.addrnum = p.billto
                   AND bd.letting = l.letting
          GROUP BY q.cdescr,
                   q.clocat1,
                   q.clocat2,
                   bd.letting,
                   l.letting,
                   l.lcontid,
                   q.cprojnum,
                   L.LETSTAT,
                   L.DATESTAT
          ORDER BY lettingdate;
    
    end;

    user9196150 wrote:
    AND l.lcontid IN v_contactid ' * this is where I would like to pass the id of the select statement above contract * ""»

    CREATE OR REPLACE PROCEDURE abstract_menu (p_letting   IN     VARCHAR2,
                                               p_results      OUT SYS_REFCURSOR)
    IS
    BEGIN
       OPEN p_results FOR
            SELECT DISTINCT
                      SUBSTR (l.letting, 3, 2)
                   || '-'
                   || SUBSTR (l.letting, 5, 2)
                   || '-'
                   || SUBSTR (l.letting, 1, 2)
                      lettingdate,
                   l.lcontid contractid,
                   SUBSTR (q.cprojnum, 1, 10) projectnumber,
                   DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route)))
                      routenumber,
                   L.DATESTAT statusdate,
                   L.LETSTAT lettingstatus,
                   (q.cdescr) jobdescription,
                   INITCAP (q.clocat1 || q.clocat2) LOCATION
              FROM vendor v,
                   vendaddr r,
                   letprop l,
                   planhold p,
                   proposal q,
                   project j,
                   propproj k,
                   bidlet bd
             WHERE     v.vendor = r.vendor
                   AND k.contid = q.contid
                   AND k.pcn = j.pcn
                   AND l.lcontid = k.contid
                   AND p.vendor = v.vendor
                   AND l.letting = p.letting
                   AND l.lcontid IN (
                                     SELECT  ll.lcontid
                                       FROM  letprop ll
                                       WHERE ll.datestat IS NOT NULL AND ll.letting = p_letting AND ll.letstat  'R'
                                    )
                   AND l.CALL = p.CALL
                   AND r.addrnum = p.billto
                   AND bd.letting = l.letting
          GROUP BY q.cdescr,
                   q.clocat1,
                   q.clocat2,
                   bd.letting,
                   l.letting,
                   l.lcontid,
                   q.cprojnum,
                   L.LETSTAT,
                   L.DATESTAT
          ORDER BY lettingdate;
    
    end;
    /
    

    SY.

  • Can I keep my itunes account in the United Kingdom and add applications to the United States on my account so that the United States pls.?

    Can I keep my itunes account in the United Kingdom and add applications to the United States on my account so that the United States pls.?

    How long you will be in the United States? To use the US store, you must be physically located in the United States, have issued US credit card and billing address in the United States on this credit card. Without it, you won't be able to change for the US store. And, you can only change stores every 90 days.

  • Insert and update by the select statement

    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.

    Florian wrote:
    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.
    >

    How can I insert and update in a table of database oracle 10g via a select statement. do not merge.

    Do you mean by using subqueries?

    Something like

    insert into whatever
      ...select statement
    
     update whatever
        set (column, column) = (select column, column ...)
    

    There is a lot of information on this topic in the online documentation

  • How to use the Type of Oracle Table values in the Select statement.

    Hello

    I get the initial set of values in the Table of Type Records of the Oracle and want to use the list of values in the Select statement.

    For example, try something like the following:

    TYPE t_record () IS RENDERING
    ID TABLEA.ID%type,
    NO TABLEA.NO%type

    );
    v_record t_record;
    T_table TYPE IS the v_record TABLE % TYPE;
    v_table t_table;

    -Code to fill the values of v_table here.

    SELECT ID, NO, COLLECT in BULK IN < some other table variabes here > FROM TABLEA
    WHERE ID IN (i) v_table USER.USER;

    I want to know how to use the Type of Oracle Table values in the Select statement.

    Something like this:

    create or replace type t_record as  object (
    id number,
    no number
    )
    /
    
    CREATE or replace type t_table AS TABLE OF t_record;
    /
    
    set serveroutput on
    declare
    
      v_table t_table := t_table();
      v_t1 t_table := t_table();
    
    begin
    
      v_table.extend(1);
      v_table(1).ID := 1;
      v_table(1).No := 10;
    
      v_table.extend(1);
      v_table(2).ID := 2;
      v_table(2).ID := 20;
    
      SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
      from TableA
      FROM TABLEA
      WHERE ID IN (select t.ID from table(v_Table) t);
    
      for i in 1..v_t1.count loop
        dbms_output.put_line(v_t1(i).ID);
        dbms_output.put_line(v_t1(i).No);
      end loop;
    end;
    /
    

    No test!

    P;

    Published by: bluefrog on March 5, 2010 17:08

Maybe you are looking for