Why a function in a SELECT FROM DUAL is faster?

(1) I have a SELECT with a function. Ex:
"SELECT DISTINCT function (...) TABLE.

(2) I've changed to SELECT it and to put the function inside a subselect with FROM DUAL. Ex:
"SELECT DISTINCT (SELECT function (...) Table (FROM DUAL).

(3) the second SELECTION is faster than the first.

I discovered this problem on my paintings and my duties. I therefore made a generic example for this forum with a common function and large table. My results:
Table has 2.196.058 records and the field is a VARCHAR2:
SELECT DISTINCT SUBSTR(field, 2) FROM Table-> Executed in 110 seconds
SELECT DISTINCT (SELECT SUBSTR(field, 2) FROM DUAL) FROM Table-> Executed in 39 seconds

Why «SELECT DISTINCT (SELECT function (...)» Table (FROM DUAL) "is faster than «SELECT DISTINCT function (...)» TABLE.


Thank you

Fernando

Dang, forum software is buggy course today

I'm sorry, I'm more confused!

Oops, now we don't want that to happen!

OK, back to the original question: "why call a function of a scalar subquery faster?
Answer: because the function can come from the cache and reused instead of the function running again.

I found this explanation step by step, which should make it clear (and it has substantially the same as what I had in mind to put in place as a test of the case later tonight), take a few minutes to read this one as well:

http://www.oratechinfo.co.UK/scalar_subqueries.html

When you compare the unit tests for your own testcase, it is clear that:
-using the fractions of a second to test the scalar subquery caching will give you many different results.
-all your table column values are distinct
Oracle knows that it is not possible to reuse a result of cache here function, given that all the results will vary and so it will re - run your function in your query for each record in your table, no caching of scalar subquery cannot be expelled.

Hopefully this will clear your doubts for good now ;)

About step 7 and 8: No 11.2 for me available (yet), so I can't say anything about this, sorry about that.

Edit

In addition, one of your previous answers was:

When I use a function within the SELECTION, I have a SCALAR subquery caching.

Now, this is not 100% true.
Depends (as always), you can have it, you will not, depends on the data allowing Oracle to reuse the results of the function of cache.

Published by: hoek on October 7, 2010 17:51

Tags: Database

Similar Questions

  • SELECT * FROM DUAL-> Can this statement to make the quick health check?

    We have a product that will "SELECT * FROM DUAL" every 5 minutes. If there is no response, it sends an incident.

    My question is:-

    DUAL is a magic table in Oracle. So, without access to an actual table in oracle, can we take out of this statement
    before report us any problem on a database? In other words, this statement could be successful, but what are the chances
    that a query on a real table can fail due to limited resources?

    Thank you
    Delphine

    This statement could be successful, but what are the chances that a query on a real table can fail due to limited resources?

    Yes

  • Anonymous - SELECT user FROM DUAL;

    I am filling a field in table LAST_UPDATED_BY VARCHAR (15) a form of APEX, with the following valid trigger:

    CREATE OR REPLACE the TRIGGER 'bi_EMPLOYEES '.
    BEFORE INSERT ON employee
    FOR EACH LINE
    BEGIN
    SELECT USER
    IN: new.last_update_by
    FROM DUAL;
    END;
    /

    The field is filled in with the value: ANONYMOUS after clicking on the button changes to. Can someone tell me why?

    ANONYMOUS is the real database user...

    Try:
    : new.last_update_by: = NVL (v ('APP_USER'), USER);

    Therefore not select necessary...

  • Having trouble selecting from a table function

    Need a function to return an array in the following format:
    WEEK_NBR               START_DATE END_DATE  
    ---------------------- ---------- --------- 
    0                      29-JAN-09  25-NOV-09 
    1                      26-NOV-09  02-DEC-09 
    2                      03-DEC-09  09-DEC-09 
    3                      10-DEC-09  16-DEC-09 
    6                      26-NOV-09  16-DEC-09 
    7                      29-JAN-09  16-DEC-09 
    The following error after the selection of a function that returns the table:
    select * from table(get_cwsr_ranges)
    Error from the 1 in the command line:
    Select * from table (get_cwsr_ranges)
    Error report:
    SQL error: ORA-06504: PL/SQL: return variables of the game results or the query types do not match
    ORA-06512: at "GET_CWSR_RANGES", line 23
    06504 00000 - "PL/SQL: return of the variable result set or query types do not match.
    * Cause: Numbers or types of columns in a query is not declared
    return type of a variable result is defined or declared two result types
    Set of variables do not match.
    * Action: Change the program or the declaration statement. Verify that the query variable
    actually we want during execution.
    >

    DDL:
    CREATE TYPE typ_date_range AS OBJECT
           (week_nbr                number,
            start_date              date,
            end_date                date   
          );
    /
    
     CREATE TYPE typ_tbl_date_ranges AS TABLE OF typ_date_range;
    /
    
    
    CREATE OR REPLACE FUNCTION get_cwsr_ranges()
    RETURN typ_tbl_date_ranges PIPELINED IS
    v_dates_table  typ_tbl_date_ranges;
    
    p_cursor     sys_refcursor;
    rec  typ_date_range := typ_date_range(NULL,NULL,NULL); 
    
    BEGIN
           
         open p_cursor for
         with sample_data as 
         (
             select 0 as  week_nbr , '29-JAN-09' as  start_date , '25-NOV-09' as end_date from dual union all                                         
             select 1 as  week_nbr , '26-NOV-09' as  start_date , '02-DEC-09' as end_date from dual union all                                         
             select 2 as  week_nbr , '03-DEC-09' as  start_date , '09-DEC-09' as end_date from dual union all                                         
             select 3 as  week_nbr , '10-DEC-09' as  start_date , '16-DEC-09' as end_date from dual union all                                         
             select 6 as  week_nbr , '26-NOV-09' as  start_date , '16-DEC-09' as end_date from dual union all                                         
             select 7 as  week_nbr , '29-JAN-09' as  start_date , '16-DEC-09' as end_date from dual  
       )
       select * 
       from sample_data;
        
    LOOP
        FETCH p_cursor INTO rec;
        EXIT WHEN p_cursor%NOTFOUND;
        PIPE ROW(Rec);
    END LOOP;
    CLOSE p_cursor;
    RETURN;
    
    END get_CWSR_Ranges;
    Any suggestions?
    create or replace FUNCTION get_cwsr_ranges
    RETURN typ_tbl_date_ranges PIPELINED
    IS
    
    BEGIN
    
      for rec in
      (
         with sample_data as
         (
             select 0 as  week_nbr , to_date('29-JAN-09', 'dd-mon-yy') as  start_date , to_date('25-NOV-09', 'dd-mon-yy') as end_date from dual union all
             select 1 as  week_nbr , to_date('26-NOV-09', 'dd-mon-yy') as  start_date , to_date('02-DEC-09', 'dd-mon-yy') as end_date from dual union all
             select 2 as  week_nbr , to_date('03-DEC-09', 'dd-mon-yy') as  start_date , to_date('09-DEC-09', 'dd-mon-yy') as end_date from dual union all
             select 3 as  week_nbr , to_date('10-DEC-09', 'dd-mon-yy') as  start_date , to_date('16-DEC-09', 'dd-mon-yy') as end_date from dual union all
             select 6 as  week_nbr , to_date('26-NOV-09', 'dd-mon-yy') as  start_date , to_date('16-DEC-09', 'dd-mon-yy') as end_date from dual union all
             select 7 as  week_nbr , to_date('29-JAN-09', 'dd-mon-yy') as  start_date , to_date('16-DEC-09', 'dd-mon-yy') as end_date from dual
        )
       select typ_date_range(week_nbr, start_date, end_date) the_type
       from sample_data
      )
      loop
        pipe row (rec.the_type);
      end loop;
    
    END get_CWSR_Ranges;
    

    and then...

    select *
    from table(cast(get_cwsr_ranges as typ_tbl_date_ranges))
    

    Published by: Tubby on December 26, 2009 19:05

    Remove the implicit conversion using explicit TO_DATE... you should always do :)

  • I use a PC and I used LR3. I'm a newcomer to LR, so patient with me! My problem is related to the import function. I have a photo library on an external hard drive. I slowly imported previews of the photos selected from the library in

    I use a PC and I used LR3. I'm a newcomer to LR, so patient with me! My problem is related to the import function.

    I have a photo library on an external hard drive. I've slowly been import previews of the photos selected from the library in my catalog, adding them during the import process - well. But now, I hit a problem. Another folder in my library contains several subfolders, each containing a number of photos (a mixture of RAW steals (naves) and jpg). I was importing found in my catalog each Subfile in turn, using the Add function, usually of the jpgs only from each Subfile. It works fine, until I reached a particular Subfile. For some reason when I try to import from it and select the secondary file as a Source, only the RAW (NEF) images appear in the preview pane (sorry, forgot the correct term for it!). I know that jpg files are in this auxiliary file on the external hard drive, because when I view its content in Windows, they are all there. But try as I can (choose the file under source, select the folder parent as a source, try to copy or move them, instead of adding them), nothing seems to work. Since they do not appear in the preview pane, I can't import them. It does appear that this a Subfile where the problem exists, but I don't see anything that is different from the others (names of files under all use the same structure - yyyy-mm-dd_custom name, and pictures in all subfolders are adopting the same denomination structure too - yyyy-mm-dd_sequential number_custom name.) NAVE/JPG. So what I am doing wrong? Any ideas please.

    It is possible that the images in this particular subfolder were taken in your camera in RAW + JPEG.  If so, you will need to go to preferences under the general tab and make sure the box "processing JPEG files files next to raw as separate photos" is checked.

    However, assuming that this is the case, there is really no reason to import the JPEG file if you already have the RAW file.

  • SELECT SESSIONTIMEZONE FROM DUAL;

    Hello

    10g, I have:
    SELECT SESSIONTIMEZONE FROM DUAL;
    SESSIONTIMEZONE                                                             
    --------------------------------------------------------------------------- 
    +01:00                                                                      
    
    1 rows selected
    What setting should I change im my session to have:
    SESSIONTIMEZONE                                                             
    --------------------------------------------------------------------------- 
    Europe/Paris
    1 rows selected
    In the documentation, it is said:
    SESSIONTIMEZONE returns the time zone for the current session. The return type is a zone offset (a type of character in the format ' [+ |]) TZH:TZM') name or of a region of time zone , depending on how the user has specified the session time zone value in the most recent ALTER SESSION statement.

    Thank you.

    I think you enjoy now from [https://forums.oracle.com/forums/thread.jspa?threadID=2331231&tstart=0 url] your other thread that's not possible because one '+ n: 00' offset corresponds to time zones?

  • Return multiple values from a function in a SELECT statement

    I hope I've provided enough information here. If not, let me know what I'm missing.

    I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).

    Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.

    For example, right now, I have:

    Table 1:
    sequence_number NUMBER (10),
    name varchar (30),
    ...

    Table2:
    Table1_seq NUMBER (10),
    action_seq NUMBER (10),
    action_date DATE,
    action_office VARCHAR (3),
    action_value VARCHAR (60),
    ...

    I can't just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.

    The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    RP.action_date (sequence_number) action_date,
    RP.action_office (sequence_number) action_office,
    RP.action_value (sequence_number) action_value
    FROM table1

    Is there a way to return multiple values in my SELECT statement or I'm going about this all wrong?

    Any suggestions?

    Thank you very much!

    Hello

    What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, like this:

    WITH     got_rnum     AS
    (
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    )
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    

    As written, this returns a single line (at most).
    I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
    In this case, add a PARTITION BY clause to the ROW_NUMBER function.
    If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
    As I don't have your tables, I'll show you the use of the tables in the scott schema.
    This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.

    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
    (
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    )
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    
    SELECT     *
    FROM     senior_emp
    ;
    

    Output:

    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
    ---------- -------------- ---------- ---------- ---------
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81
    

    Moreover, one of the conditions to the query you posted has been

    action_office     LIKE 'E'
    

    which equals

    action_office     = 'E'
    

    (AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
    Did you mean say that or did you mean something like this:

    action_office     LIKE 'E%'
    

    Instead?

  • Select from 2 dimensions collection returned by a pipeline-table-function

    With the help of 10 gr 2

    A pipeline function returns a collection of an object oriented sub-collection:


    TYPE TXT_ARRAYTYPE IS TABLE OF THE VARCHAR2 (2000);

    type txt2dtable_objtype as object)
    txt2dtable txt_arraytype;

    type txt2dtable_arraytype as the txt2dtable_objtype table;


    FUNCTION getTxtList (start_date IN DATE) RETURN PIPELINED txt2dtable_arraytype
    ....



    How can I select from the function for each element varchar2 grouped by line number (the top-level collection) txt2dtable_arraytype?

    Example:

    Text of RowNum
    1 Hello
    1 World
    2 my
    2 name
    2 is
    2 Nuerni!
    3 How
    ....


    A select statement can be used for an external, OIC - / JDBC / follow App would be great!

    Any ideas?

    Kind regards
    Nuerni

    Something like this:

    SQL>create type txt_arraytype is table of varchar2(2000)
      2  /
    
    Type created.
    
    SQL>create type txt2dtable_objtype as object ( txt2dtable txt_arraytype )
      2  /
    
    Type created.
    
    SQL>create type txt2dtable_arraytype as table of txt2dtable_objtype
      2  /
    
    Type created.
    
    SQL>create or replace FUNCTION getTxtList (start_date in date)
      2  return txt2dtable_arraytype pipelined
      3  is
      4  begin
      5    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'Hello', 'World' ) ) );
      6    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'My', 'name', 'is', 'Anton' ) ) );
      7    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'And', 'this', 'is', 'an', 'example' ) ) );
      8    return;
      9  end;
     10  /
    
    Function created.
    
    SQL>
    SQL>select rn, y.column_value
      2  from ( select rownum rn
      3              , object_value
      4         from table( getTxtList( sysdate ) )
      5       ) x
      6     , table( x.object_value.txt2dtable ) y
      7  /
    
            RN COLUMN_VALUE
    ---------- -----------------------------------------------------------------------------------------
             1 Hello
             1 World
             2 My
             2 name
             2 is
             2 Anton
             3 And
             3 this
             3 is
             3 an
             3 example
    
    11 rows selected.
    
    SQL>
    

    Anton

  • SQLite Select * from table1 - cannot see last line

    Hello

    I did some testing with SQLite component on the Simulator and ran into a problem. When I try to retrieve the data from the database (storage works great... open the db to an observer and data file has been stored properly), I can't get the last line of the query. I have something in the sense of the following:

    try {
          Statement _statement = m_db.createStatement("SELECT * FROM TABLE1");
          _statement.prepare();
          _statement.execute();
          Cursor _cursor = _statement.getCursor();
          if (_cursor != null) {
    
            while (_cursor.next()){
                Row _row = (Row)_cursor.getRow();
                // Read row. For example:
                int idx1 = _row.getColumnIndex("id");
                int idx2 = _row.getColumnIndex("name");
    
                String _id           = _row.getString(idx1);
                String _name         = _row.getString(idx2);
            }
          }
          _statement.close();
          _cursor.close();
        } catch (Throwable e) {
          Dialog.alert("unable to get row data");
        }
    

    The first problem is that _cursor.next does not succeed, and the loop is not executed. If I change the code to force it to enter the loop (ie. cursor.first and run the .getPixel etc... in any case), I always get the LAST row, even when I use the position (1, 2, 3, 4... etc) function. It's pretty boring. I develop this 5.0 and testing with 9700 Simulator. Any ideas why I would see only the last row?

    Why the next file in the thropugh code above, I can't retrieve a row in the database?

    Note I tried dogin cursor.first ()... . Run the .GetPixel and the. next(), don't always gets me the line after line and the other always returns false. I do a select empty in the database, all lines should be there (checked the structure of data in another program... it is fine), no idea why it isn't here?

    Thanks in advance.

    Figured this out, the _statement.execute (); should not be there.

  • Why Table function is not allowed on the collections defined in PLSQL?

    We all know that we can use the function table on collections defined as database object type. Why cant Oracle provide this function for defined collections in PLSQL?

    For prior 12c version you can play around with pipelined functions.
    
    SQL> create or replace package emppkg
      2  as
      3    type rec is record (empno integer, ename varchar2(100));
      4    type tbl is table of rec;
      5
      6    function get (pdeptno in integer) return tbl pipelined;
      7  end;
      8  /
    
    Package created.
    
    SQL> show err
    No errors.
    SQL> create or replace package body emppkg
      2  as
      3    function get (pdeptno in integer) return tbl pipelined
      4    is
      5       lrec rec;
      6    begin
      7       for i in (select empno, ename from emp where deptno = pdeptno)
      8       loop
      9          lrec.empno := i.empno;
     10          lrec.ename := i.ename;
     11          pipe row(lrec);
     12       end loop;
     13
     14       return;
     15    end;
     16  end;
     17  /
    
    Package body created.
    
    SQL> show err
    No errors.
    SQL> select * from table(emppkg.get(10));
    
         EMPNO ENAME
    ---------- --------------------
          7782 CLARK
          7839 KING
    
    SQL> select * from table(emppkg.get(20));
    
         EMPNO ENAME
    ---------- --------------------
          7369 SMITH
          7566 JONES
          7788 SCOTT
          7876 ADAMS
    
    SQL> select * from table(emppkg.get(30));
    
         EMPNO ENAME
    ---------- --------------------
          7499 ALLEN
          7521 WARD
          7654 MARTIN
          7698 BLAKE
          7844 TURNER
    
    SQL>
    
  • Select from the sum

    Hello
    I solve the problem much more complex, but I'm stuck on a simple question:
    I get ORA-00936 missing expression all the time in this sql:
    SELECT (SUM (SELECT ma_fonction (table.column) of double)) AS my_sum, table.anothercolumn FROM table

    I get the same thing if I just do something as simple as:

    SELECT id, table FROAM (SUM (SELECT 1 + 1 double) as double my_sum)

    What's not here? I know it's something with the amount and the select after it, but what is it? Please crazy me :)

    Thank you very much

    Published by: koszta5 on November 11, 2010 05:15

    Something like that?

    create function my_function(Indata number) return number
    as
    begin
    Return Indata;
    end;
    
    With table_name as (
    Select 1 column_1, 'das' anothercolumn from dual union all
    Select 1, 'des' from dual union all
    Select 1, 'dis' from dual union all
    Select 1, 'dos' from dual union all
    Select 1, 'dus' from dual
    )
    SELECT (SUM(my_function(column_1))) AS my_sum, anothercolumn FROM table_name group by anothercolumn
    
  • Update using a function in the select statement

    Hello

    Is it possible to do the follwing.

    I tabele and a custom function, the custome service will update the column (amount) of the table based on the value of going through the function of the select statement.

    SELECT id, stock, where an id = get_update (id);

    Now


    Get_update function will return the same id I'm passing and update the column amount to a value in the
    table a.

    When I run the satament selection I have the updated data in the column amount in my first executtion, but if execute the same statement, again, I see the changes reflected. is it possible to get data updates to the first performance himself.

    the function is of type PRAGMA AUTONOMOUS_TRANSACTION

    Concerning

    Indeed a strange requirement and probably not the way to go in a production environment. But anyway is a way to achieve your goal

    SQL> create table a
    as
       select   12 id, 500 amount from dual
       union all
       select   13 id, 600 amount from dual
    /
    Table created.
    
    SQL> create or replace type a_typ as object (id number, amount number)
    /
    Type created.
    
    SQL> create or replace function get_id (pid number)
       return a_typ
    is
       pragma autonomous_transaction;
       l_a_typ   a_typ := a_typ (null, null);
    begin
          update   a
             set   amount = 800
           where   id = pid
       returning   id, amount      into   l_a_typ.id, l_a_typ.amount;
    
       commit;
    
       return l_a_typ;
    end get_id;
    /
    Function created.
    
    SQL> select   id, d.a_typ.amount amount
      from   a, (select get_id (13) a_typ from dual) d
     where   id = d.a_typ.id
    /
            ID     AMOUNT
    ---------- ----------
            13        800
    1 row selected.
    
  • Why the volume speaker icon disappear from the Office

    WHY THE VOLUME SPEAKER ICON DISAPPEAR FROM THE OFFICE

    Hi FREDERICKLOU,

    Follow the steps below to make sure that the volume icon is set to display in the notification bar:

    1. Click the arrow in the notification bar, click Customize and click Start > Control Panel > Notification area icons
    2. Use the drop-down list next to the Volume and select Show icon and notifications
    3. Click OK

    Let us know if that helps.

  • What privileges granted to select from all the PDB files

    Why the two selected does not return the same result? Or if you want the broader question - what privileges granted to select from all the PDB files.


    I want to leave common user that I created to select and see all of the synonyms of all PDB files.


    conn / as sysdba

    create user c##nir identified by c##nir container=all;

    grant connect,dba,resource to c##nir container=all;
    grant select on cdb_synonyms to c##nir container=all;

    select CON_ID  from cdb_synonyms  group by CON_ID;

      CON_ID
    ----------
      
    1
      
    4
      
    11
      
    10
      
    14
      
    5
      
    8
      
    13
      
    3
      
    7
      
    15
      
    6
      
    12
      
    9

    conn c
    ##nir/c##nir

    select CON_ID  from cdb_synonyms  group by CON_ID;

      CON_ID
    ----------
      
    1

    select CON_ID  from containers(dba_synonyms)  group by CON_ID
      
    *
    ERROR at line
    1:
    ORA-00942
    : table or view does not exist

    You must use the CONTAINER_DATA clause:

    ALTER USER ##nir set container_data = container c all = current;

    After running the above command, try to select again to cdb_synonyms and you will see the data of all containers.

    Read more in my Post of Blog

  • Insert into MDQ_OLD select * from table (lt_monitorMdq);

    I'm trying to insert into a table that has only a single column, which is a column of a user defined type (UDT). The UDT is nested, that is one of the attributes of the UDT is an another UDT.

    I aim to insert into the table like this pseudo-code:

    INSERT INTO T1 SELECT * FROM THE UDT;

    CREATE TABLE MDQ_OLD (myMDQ UDT_T_MONITOR_MDQ)

    NESTED TABLE myMDQ

    (T1_NEW) ACE STORE

    THE NESTED TABLE MONITOR_MDQ_PRIM_RIGHTS

    STORE AS T2_NEW);

    The MONITOR_MDQ_CLI procedure. Read below returns the parameter lt_monitorMdq which is a UDT type as announced. The statement "insert into select MDQ_OLD * table (lt_monitorMdq);" fails, while the second insert statement works.

    Is it possible to get the first statement of work?

    I'm on Oracle 11 g 2.

    DECLARE

    lt_monitorMdq UDT_T_MONITOR_MDQ;

    BEGIN

    MONITOR_MDQ_CLI. Reading (TRUNC (SYSDATE),

    TRUNC (SYSDATE),

    NULL,

    NULL,

    "MILLION BTU.

    lt_monitorMdq); -Note lt_monitorMdq is an OUT parameter

    -This insert does not work

    Insert into MDQ_OLD select * from table (lt_monitorMdq);

    BECAUSE me in 1... lt_monitorMdq.count

    LOOP

    Dbms_output.put_line ('lt_monitorMdq: ' | .mdq_id lt_monitorMdq (i));

    -This integration works

    INSERT INTO MDQ_OLD (MYMDQ)

    VALUES (UDT_T_MONITOR_MDQ (UDT_R_MONITOR_MDQ)

    lt_monitorMdq (i) .gasday,

    1,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    () UDT_T_MONITOR_MDQ_PRIM_RIGHT

    () UDT_R_MONITOR_MDQ_PRIM_RIGHT

    1,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    (NULL)));

    END LOOP;

    END;

    have you tried:

    INSERT INTO MDQ_OLD (myMDQ) VALUES (lt_MonditorMDq);

    curiosity:

    Is there a particular reason, why you have created a table with a single column of type UDT instead of:

    CREATE TABLE... OF UDT_T_MONITOR_MDQ;

    I can tell you from experience that using a nested table, you can easily query the data in the nested table.

    MK

Maybe you are looking for