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

Tags: Database

Similar Questions

  • How to use the select statement in loop for

    Hi all

    My question is can I use a select statement in for loop like as follows.

    for the key in the selection of one_table key.

    When I use this am getting an error as found select invalid I ID

    How to select a statement use in loop for

    Please suggest me.

    Thank you
    Sree

    Hello

    You can use code below

    For key in (select button from table_a)
    loop
    If key.key = 1 then
    -insert statement
    on the other
    -Select statement
    end loop;

    Thank you
    Naveen.

  • 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.

  • How to use the selection tool to resize a text box? Before I was able to click on the text box with the selection too in order to resize, but now I click on it and it only gives me 'path' or 'anchor' options.

    How to use the selection tool to resize a text box? Before I was able to click on the text box with the selection too in order to resize, but now I click on it and it only gives me 'path' or 'anchor' options.

    Ashley,

    What about window > show the rectangle enclosing (Ctrl / Cmd + Shift + B to toggle)?

  • In version 5, how to use the selection tool to move items?

    I can use the selection tool to select objects, but when I try to drag, nothing happens. My solution is to use the selection tool to select an object, then use the transform tool to drag the object in its new position. Any help is greatly appreciated.

    Start by restoring your InDesign preferences. Tutorial here:

    http://PFL.com/TRB

  • How to display the data type long using the select statement

    Hai All

    I have to select the text of a view. But the text is declared as long and I need to see full view

    When I use this

    Select the text in all_views where view_name = "DAILY_ATTEND_VIEW";

    I have got only half of a select statement

    Concerning

    Srikkanth.M

    Hello

    SQL> SET LONG 100000
    SQL> select text from user_views
      2   where view_name='MVIEW';
    
    TEXT
    ------------------------------------------
    select e.empno,e.deptno,d.dname
    from emp@sdblink e,dept@sdblink d
    where e.deptno=d.deptno
    

    But it is limited to sql alone. If you use the double click TOAD on the text column in the grid will show you the entire SQL views.
    Unfortunately, there is limitation to consider,
    The largest value that you return from the function would be 32 k (RETURN VARCHAR2), both.

    Twinkle

  • Help: How to use the Case statement in the ODI11g Interface?

    Hello
    My basic source I get 'Year' values and I want that these values result code in the interface and after translation want to push on the target system.
    Example:
    Database source, I get value for
    Year
    2010
    2011
    2012

    When I get the year 2010 I want to change the value in "FY10".
    When I get year 2011 I want to change the value in "FY11.
    and even for the year 2012 to "FY12.
    I've tried to make the Case statement, but had no success.
    I don't want to create the lookup table in the source system.
    Any help in this matter.

    Thank you

    Concerning
    Sher

    Published by: Sher Ullah Baig on August 26, 2012 17:52

    CASE
    WHEN source_column = '2010' THEN 'FY10.
    WHEN source_column = '2011' and THEN 'FY11.
    WHEN source_column = '2012' and THEN 'FY12.
    END

  • Update using the Select statement

    I have a requirement of the main table was updated. Here is an example
    Example (a) works in PL SQL but does not work in Forms6i.
    Example (b) works in PLSQL so in Forms 6i.

    I need work example (a) in forms 6i. What is the solution


    one)
    UPDATE fman_validation_master SET TOT_HRS = TOT_HRS +.
    (SELECT SUM (FAV. H TOT_HRS)
    OF FMAN_ACTQTY_VALIDATION FAV
    WHERE fman_validation_master. = PROJECT: CONTROL. PROJECT AND
    fman_validation_master. PROJECT = fav. PROJECT AND
    fman_validation_master. ACTIVITY_CODE = FAV. ACTIVITY_CODE
    FAV GROUP. PROJECT, FAV. ACTIVITY_CODE
    ) where of the = project: CONTROL. PROJECT;


    (b)
    UPDATE fman_validation_master SET TOT_HRS =
    (SELECT SUM (FAV. H TOT_HRS)
    OF FMAN_ACTQTY_VALIDATION FAV
    WHERE fman_validation_master. = PROJECT: CONTROL. PROJECT AND
    fman_validation_master. PROJECT = fav. PROJECT AND
    fman_validation_master. ACTIVITY_CODE = FAV. ACTIVITY_CODE
    FAV GROUP. PROJECT, FAV. ACTIVITY_CODE
    ) where of the = project: CONTROL. PROJECT;

    Hello

    According to Oracle 8.1, you can say:

    UPDATE  table_x
    SET     column_a = exp;
    

    where exp is any expression, or

    UPDATE  table_x
    SET     column_a = (ssq);
    

    where ssq is now called a scalar subquery. Oracle 8.1 sometimes allowed scalar subqueries in places where the documentation did not say that they were allowed. The first statement is an example, when you use

    tot_hrs + (ssq)
    

    as an expression. It works in SQL * Plus and also in PL/SQL, but (apparently) not in the forms.

    Re-write your UPDATE statement so that the scalar subquery appears in itself to the right of the sign =, like this:

    UPDATE     fman_validation_master
    SET     tot_hrs =
         (
         SELECT     fman_validation_master.tot_hrs + SUM (fav.tot_hrs)
         FROM     fman_actqty_validation     fav
         WHERE     fman_validation_master.project          = fav.project
           AND     fman_validation_master.activity_code     = fav.activity_code
         )
    WHERE     project = :control.project;
    

    In other words, just move the original fman_validation_master.tot_hrs (to which you add the SUM) of the main request in the subquery.

  • [JS CS5] How to get the selected state of a multi-state object

    Does anyone know if there is a way to identify the State of a multi-state object is selected?

    You can select different States of an object of several State in the States Panel.

    In the object model.

    Mon_etat = app.selection [0].states.item (0);

    myState.active = true;

    .. .all the first State to the DSO. But I can't understand how to identify the State in which is currently visible. This doesn't seem to be possible in the object model, unless I'm missing something. Any ideas?

    Hey!

    Take a look at 'activeStateIndex' of MSO.

    Hope that helps.

    --

    tomaxxi

    http://indisnip.WordPress.com/

  • How to write the SELECT statement

    Commission of the CARDS
    0-20 0
    21-25 500
    26-31 650
    32-36 850
    37 > 1050


    If a PERSON sells 28 cards in one month, commission would be calculated as below.

    25 * 500 = 12500
    3 * 650 = 1950

    Total commission 14450

    I guess that's what you're looking for...

    CREATE TABLE WG (A NUMBER);

    INSERT GT VALUES (0);

    INSERT GT VALUES (28);

    SELECT * FROM GT

    0
    28

    SELECT THE CHECK BOX
    WHEN IS > = 0 AND<=20 then="">
    WHEN WAS > = 21 AND HAS<=25 then="">
    WHEN WAS > = 26 AND HAS<=31 then="">
    WHEN WAS > = 32 AND HAS<=36 then="">
    WHEN > = 37 THEN 36 * 850 + (A-36) * 1050
    ON THE OTHER
    NULL VALUE
    END TEST
    THE GT;

    Output:

    0
    14450

    Thank you...

  • Insert a variable + string using the select statement with cfquery

    I'm doing an insertion by a select statement where the insert for one of the fields should be a combination of a vaule comes from the selection and concatenated with a string of text. Is this possible and if what the correct syntax so? Here is an example of what I'm trying, but does not.

    < name cfquery = "createnote" datasource = "#application.datasource #" >
    INSERT INTO gtbl_notes (notedate, strCustomerID, notetype, note, notecreatedby)
    SELECT "#currentdate #", strCustomerID, "miscellaneous", "#gtbl_people.email # DELETED because of HARD BOUNCE ', 'Bounce Routine.
    OF gtbl_people, gtbl_bounces
    WHERE gtbl_bounces.email = gtbl_people.email AND gtbl_bounces.subscriber = 1 AND gtbl_bounces.status = 2

    < / cfquery >

    Any input would be greatly appreciated.

    Concatonation is possible with most, if not all of the databases.  The syntax is a specific software and you do not your specify.

  • Creating a table using the Select statement of the physical layer

    Hello

    I use 10G, and I have the sub query in my physical layer. I chose the type of Table as Select and gave the SQL below. When I say the number of lines of update updates lines 93, that is correct, but does not show me the columns, or when I say display data, it does not show me the data, please see if I'm doing something worng. Thanks for your time and your help.

    Select (select program_id, project, actvty_id, commitment_date, row_number() over (partition by order project by commitment_date desc) as rnk project, actvty_id, program_id, commitment_date)
    of project_detail) a
    where rnk = 1

    Yes, create columns individually and click view data, you'll be able to get data

  • How to use the United States-International keyboard in Windows 8

    Hello

    I can't find a way to US International keyboard configuration in Windows 8. It's really frustrating because I like working with an English keyboard, but I often have to write Spanish accents or special characters.
    Best regards, Miguel.

    Hello

    Took me a little while to understand it as it is not obviously accessible somehow...
    Please, try the following. Go to 'Control Panel\Clock, language and Region\Language', click English (United States)... 'options', then 'Add an input method', search for [QWERTY] United States International Touch Keyboard layout (in my case) or similar; then 'Add '.
    Once he shows up the international sort, DELETE the default English input method.
    You should then be able to n, a e i o u without delay by pressing first the focus then the letter
    Then hold down the Ctrl and Alt keys +! do
    Then hold down the Ctrl and Alt keys +? do
    I hope this helps.
    Pablo
  • How to use a variable as a column name in a select statement

    Hello, I am using

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

    PL/SQL Release 11.2.0.3.0 - Production

    I have a procedure looking for groups that have not been updated for the current month. The columns are month_01, month_02, month_03 etc. I'm becoming if I can automate every month, but I need to be able to use a variable as the name of the column for the month. Can someone help me with this?

    Example of Table

    CREATE TABLE TEST_TABLE
    (
      IDENTITY_CODE      NUMBER(10),
      YEAR_S             NUMBER(5),
      MONTH_01           NUMBER(18,2),
      MONTH_02           NUMBER(18,2),
      MONTH_03           NUMBER(18,2),
      MONTH_04           NUMBER(18,2),
      MONTH_05           NUMBER(18,2),
      MONTH_06           NUMBER(18,2),
      MONTH_07           NUMBER(18,2),
      MONTH_08           NUMBER(18,2),
      MONTH_09           NUMBER(18,2),
      MONTH_10           NUMBER(18,2),
      MONTH_11           NUMBER(18,2),
      MONTH_12           NUMBER(18,2) 
    );
    INSERT ALL
    INTO TEST_TABLE VALUES(640,2015,124,123,125,126,127,128,547,888,987,567,145,685)
    INTO TEST_TABLE VALUES(098,2015,587,874,0,587,652,222,444,777,885,999,657,547)
    INTO TEST_TABLE VALUES(608,2015,587,874,687,587,652,222,444,787,885,999,657,547)
    select 1 from dual;
     

    Here's my current procedure

    CREATE OR REPLACE PROCEDURE RRM_EMAIL_NOTIFICATION IS
    
    v_output VARCHAR2(10000);
    v_message VARCHAR2(1000);
    v_date date;
    cursor v_check is 
    SELECT *
      FROM (SELECT '640' AS ds FROM DUAL
            UNION ALL
            SELECT '098' AS ds FROM DUAL
            UNION ALL
            SELECT '608' AS ds FROM DUAL
            UNION ALL
            SELECT '618' AS ds FROM DUAL
            UNION ALL
            SELECT '617' AS ds FROM DUAL
            UNION ALL
            SELECT '614' AS ds FROM DUAL
            UNION ALL
            SELECT '610' AS ds FROM DUAL
            UNION ALL
            SELECT '616' AS ds FROM DUAL
            UNION ALL
            SELECT '643' AS ds FROM DUAL)
    WHERE LPAD (ds, 3, '0') NOT IN
              (SELECT DISTINCT (SUBSTR (IDENTITY_CODE, 2, 3)) AS Blah_Blah_Blah
                 FROM TEST_TABLE
                WHERE     month_03 <> 0
                      AND year_s = 2015
                      AND (   SUBSTR (IDENTITY_CODE, 2, 3) = '640'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '098'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '608'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '618'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '617'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '614'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '610'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '616'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '643'));
    
    BEGIN
    v_date := SYSDATE;
    open v_check;
    loop 
    fetch v_check into v_output;
    exit when v_check%NOTFOUND;
    v_message := v_message || chr(13) || v_output;
    END LOOP;
    close v_check;
       
    send_mail('The RRM one-time initiatives that have not been processed for '||v_date|| ' are ' || chr(13) ||v_message,'[email protected]','RRM ONETIMES NOT PROCESSED FOR ' || v_date);
       
    END RRM_EMAIL_NOTIFICATION;
     

    I need to be able to substitute the name e.g. MONTH_01 with a variable column so that it will be MONTH_ | "" some months "

    A variable can be created as v_month: = 'month_ | TO_CHAR (T_DATE, 'MM')

    If I'm not mistaken that should come out as month_03 for March

    The output should be in an email as follows:

    Capture.JPG

    Something like:

    CREATE OR REPLACE PROCEDURE RRM_EMAIL_NOTIFICATION IS

    v_output VARCHAR2 (10000);

    v_message VARCHAR2 (1000);

    date of T_DATE;

    v_check SYS_REFCURSOR;

    BEGIN

    T_DATE: = SYSDATE;

    Open the v_check FOR

    Q' {}

    SELECT *.

    FROM (SELECT '640' DS DUAL FROM

    UNION ALL

    SELECT '098' LIKE ds FROM DUAL

    UNION ALL

    SELECT '608' LIKE ds FROM DUAL

    UNION ALL

    SELECT '618' LIKE ds FROM DUAL

    UNION ALL

    SELECT '617' LIKE ds FROM DUAL

    UNION ALL

    SELECT '614' LIKE ds FROM DUAL

    UNION ALL

    SELECT '610' LIKE ds FROM DUAL

    UNION ALL

    SELECT '616' LIKE ds FROM DUAL

    UNION ALL

    SELECT '643' DS DUAL FROM)

    WHERE LPAD (ds, 3, '0') NOT IN

    (SELECT DISTINCT (SUBSTR (IDENTITY_CODE, 2, 3)) AS Blah_Blah_Blah

    FROM TEST_TABLE

    {WHERE month_}' | TO_CHAR (T_DATE, 'MM') | Q'{ <> 0

    AND year_s = 2015

    AND SUBSTR (IDENTITY_CODE, 2, 3))

    '640'

    '098'

    , ' 608 "

    '618'

    '617'

    '614'

    '610'

    '616'

    '643')

    )

    }';

    loop

    extract the v_check in v_output;

    When the output v_check % NOTFOUND;

    v_message: = v_message | Chr (13) | v_output;

    END LOOP;

    close v_check;

    send_mail ("one-time initiatives the RRM that haven't been treated for ' |") T_DATE | «are» | Chr (13) | v_message,' [email protected]',' ONETIMES UNPROCESSED for RRM ' | T_DATE);

    END RRM_EMAIL_NOTIFICATION;

  • Need to know how long takes the Select statement of the cursor?

    Hi people
    I want to know the duration of execution of the cursor in a stored procedure.

    Piece of my code is provided below.

    procedure Process_PCN_MAT_Custs)
    p_PCN_OID in varchar2,
    p_days_back number
    ) is
    number of vcount;
    v_newoid varchar2 (16);
    date of pcn_create_date;
    T_DATE: = to_char (sysdate, ' dd/mm/yyyy hh24:mi:ss');
    cursor (SAP_Customers)
    x_PCN_OID varchar2,
    number of x_days_back
    date of x_pcn_create_date
    ) is
    Select
    KUNNR,
    Max (soldflag) soldflag,
    Max (shipflag) shipflag,
    Max (endflag) endflag,
    Max (custName) custname
    de)
    Select / * + DRIVING_SITE (bims_pcn_shipments) * /.
    KUNNR,
    SoldFlag,
    ShipFlag,
    EndFlag,
    custName
    Of
    bims_pcn_shipments_mview

    where
    material_number in (select sap_material_no from the pcn.material where pcn_oid = x_PCN_OID)
    and bdr_date > (x_pcn_create_date - x_days_back)

    UNION
    Select / * + DRIVING_SITE (bims_pcn_shipments) * /.
    KUNNR,
    SoldFlag,
    ShipFlag,
    EndFlag,
    custName
    Of
    bims_pcn_backlog_mview

    where
    material_number in (select sap_material_no from the pcn.material where pcn_oid = x_PCN_OID)
    and bdr_date > (x_pcn_create_date - x_days_back)

    )
    Group
    KUNNR;
    dbms_output.put_line to_char (v_date);

    Begin
    Open SAP_CUSTOMERS
    ---
    ---
    ---
    close SAP_CUSTOMERS
    end

    I get an error of compilation for this line [T_DATE: = to_char (sysdate, ' dd/mm/yyyy hh24:mi:ss');].
    Saying "+ Error (95,12): PLS-00103: encountered the symbol"="when expected as follows: constant exception < an ID > < a double quote delimited identifier > table Fedya double Ref char time timestamp interval date binary character national nchar"< an ID >"symbol has been replaced for"="continue +.»

    I would be grateful if someone can help me solve this weired compilation error.

    Thank you
    Vineet

    Then you need to go to the function [DBMS_UTILITY. GET_TIME. http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_util.htm#sthref7809].

    Something like that...

    n := dbms_utility.get_time;
    
    dbms_output.put_line( (dbms_utility.get_time-n)/100) || ' seconds....' );
    

    Published by: Karthick_Arp on January 16, 2009 05:07

Maybe you are looking for

  • Satellite Z830 - cannot install the Eco utility because of the wrong version of the OS

    I installed Windows 8 from the original CD (not an update) and installed many pilots. When I try to install the Eco utility, it goes all the way to the end but then tell me that the operating system is not supported with load (translated) and cancel

  • Vista and Sony DCR HC32 DV download compatible question - not able to find the driver

    Hello My laptop Vista's window isn't able to recognize my Sony DCRHC32 when I use IEEE 1394 or USB cable. It says device not found driver. Of all the posts I've read online, it says Windows Vista and above OS should have all the necessary drivers to

  • Change multiple file permissions?

    I updated from XP PC to a laptop running Windows 7. I'm trying to transfer files from my XP on my laptop. The files have access denied because of incorrect file permissions. I know how to change the permissions individually but as I have a few files

  • The trigger of a composition Gets a box when downloaded!

    I'm doing a site and downloaded on a mine test server page, in Site-Preview of Muse composition making it a line in the section you're hovering works perfectly fine, but when I download this site on my test server the trigger Gets a contour.Does anyo

  • VCRUNTIME140.dll and MSVCP140.dll Photoshop mistakes

    Hello! Lately I have big problems with my Photoshop CC (2015.5).  In an instant, no reason it just stopped working.When I tried to open any file in PS, something like: "Photoshop.exe error: can't open the program because of lack of .. VCRUNTIME140.dl