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

Tags: Database

Similar Questions

  • Insert into select * from table 3. -is on the agenda by the needless?

    I've got an example of script, it will work for any table, so I don't bother with the full ddl.

    ----------------------------------------------------------------------------
    create table test in select * from hotels where 1 = 2;

    Insert into test select * from Hotels by city;

    Select the city from the trial;

    -drop table test is serving;
    -----------------------------------------------------------------------------

    The amazing thing is, that the city is ordered alphabetically,
    but you would say it is that an operation order is irrelevant.

    Any ideas on that?

    This will still work?

    Edited by: FourEyes on December 8, 2008 22:55

    Edited by: FourEyes on 8 December 2008 22:56

    Edited by: FourEyes on 8 December 2008 22:56

    Hello

    The [SQL Oracle 10 language reference | http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#sthref9371] manual says:

    «In regards to the ORDER BY clause from the subquery in the DML_table_expression_clause, you place your order is guaranteed only for the inserted rows and only within each extension table.» Orders new lines with regard to existing lines is not guaranteed. »

  • Problem with "select * from table" for dynamic IN the list

    I have a 'for loop' based a query that does not work. The query is supposed to return the name of the table, the data type and the name of the column in the columns poses a number of name filters. The problem I have is when I run the query into a TOAD with:

    schema_list value SCOTT, MED and the clause of 'in' as ' to (select * from table (DATAPUMP_UTIL.in_list_varchar2 (:schema_list))))»

    The query returns the expected lines.

    When I have it in my code as shown below it returns no rows. I don't know what hurts me, but any help would be great! I'm on Oracle 11.1.0.6.0.
    PROCEDURE export_schema_ondemand (schema_list VARCHAR2, encrypt_file NUMBER default 0, mask_sensitive_data NUMBER default 0) IS  
        ...
        schema_list_t := my_package.in_list_varchar2(schema_list);
        ... 
        for c1 in
           (
            with ok_to_mask as (
            select 
                owner,
                table_name, 
                column_name
            from   
               all_tab_columns
            where
                owner in (select * from table(schema_list_t))
            minus
            (SELECT 
                c.owner,
                p.table_name,
                cc.column_name
            FROM 
                all_cons_columns cc, 
                all_constraints p,
                all_constraints c
            WHERE 
                c.owner in (select * from table(schema_list_t))
                c.constraint_type = 'R'
                AND p.owner = c.r_owner
                AND p.constraint_name = c.r_constraint_name
                AND cc.owner = c.owner
                AND cc.constraint_name = c.constraint_name
                AND cc.table_name = c.table_name
            UNION ALL
            SELECT 
                c.owner,
                cc.table_name,
                cc.column_name
            FROM 
                all_cons_columns cc,
                all_constraints p,
                all_constraints c
            WHERE
                p.owner in (select * from table(schema_list_t))
                AND p.constraint_type in ('P','U')
                AND c.r_owner = p.owner
                AND c.r_constraint_name = p.constraint_name
                AND c.constraint_type = 'R'
                AND cc.owner = c.owner
                AND cc.constraint_name = c.constraint_name
                AND cc.table_name = c.table_name))
            select 
                atc.table_name as mask_tab, 
                atc.column_name as mask_col, 
                atc.data_type as mask_type
            from   
                all_tab_columns atc,
                ok_to_mask otm
            where
                atc.owner = otm.owner
                and atc.table_name = otm.table_name
                and atc.column_name = otm.column_name
                and atc.owner in (select * from table(schema_list_t))
                and 
                (
                atc.column_name like '%LAST%NAME%'
                or atc.column_name like '%FIRST%NAME%'
                or atc.column_name like '%NAME_LAST%'
                or  atc.column_name like '%NAME_FIRST%'
                or  atc.column_name like '%ENAME%'
                or atc.column_name like '%SSN%'
                or atc.column_name like '%DOB%'
                or atc.column_name like '%BIRTH%'
                )
                and atc.column_name not like '%PHYSICIAN_%'
                and atc.column_name not like '%DR_%'
                and atc.column_name not like '%PROVIDER_%'
                and atc.column_name not like 'PRESCRIBER_%'     
           )
          loop
             ...
    
    FUNCTION in_list_varchar2 (p_in_list  IN  VARCHAR2)  RETURN VARCHAR2_TT is
    
        l_tab   VARCHAR2_TT := VARCHAR2_TT();
        l_text  VARCHAR2(32767) := p_in_list || ',';
        l_idx   NUMBER;
            
    BEGIN
        LOOP l_idx := INSTR(l_text, ',');
            EXIT WHEN NVL(l_idx, 0) = 0;
            l_tab.extend;
            l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
            l_text := SUBSTR(l_text, l_idx + 1);
        END LOOP;
    
        RETURN l_tab;
            
    END in_list_varchar2;
    Published by: BluShadow on June 29, 2011 16:11
    addition of {noformat}
    {noformat} tags.  PLEASE READ {message:id=9360002} TO LEARN TO DO THIS YOURSELF.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

    Hello

    If you have a query that works well when you launch it directly, and that breaks down when you start with a procedure, this can be a problem of privileges.

    Points of view ALL_ * shows only the objects you have access, but using a procedure, privileges must be granted directly to the user and not with a role.

    You should check the SELECT privileges to your user through roles and give them directly to the user.

    Hope this will help.

    Sylvie

  • Values are inserted into a SQL PL table to a database table

    Hello

    Here's my dilemma.

    I have values inserted into a pl sql table which I have collected from a web page. Now, I need to add these values in a database table. I see the values as 1-'AA', 2 = 'BB' etc.

    I use the following code to insert into a table outside in the database, and it seems to be crashing.

    for me in app_table.first... loop app_table. Last
    r_convention (i) .priority_country_code: = app_table (i);

    insert into test_countries
    values (test_seq, tion (i) .r_convention (i) .priority_country_code);

    commit;

    end loop;
    When I run this code, I see the values. But he goes to the first value and then crashes and does not pass by the
    the rest of the values. What I'm missing here?

    Thank you!

    and move the validation outside of the loop :-)

  • How to insert into a GLOBAL TEMPORARY TABLE and get the data from it?

    The requrement is
    Split the string ENTRY point on the base and store it in a Collection. And the values of the collection will be stored in a global temporary table. Then, I'm updating some other table based on the data from the temporary table.

    There is in fact no error message. But there is no data in the temporary table and also no change in the update statement

    First of all, I'm creatiing a global temporary table only once outside the procedure.

    CREATE GLOBAL TEMPORARY table GLt (data_element number)


    create or replace procedure test_proc (p_in_string VARCHAR2) is
    i the number: = 0;
    number of POS: = 0;
    CLOB lv_str: = p_in_string;
    p_delim VARCHAR2 (1): = ', ';

    TYPE t_array IS TABLE OF VARCHAR2 (20) INDEX directory.
    t_array channels;

    BEGIN

    -cutting of string input and store in the strings (i) collection

    POS: = instr (lv_str, p_delim, 1, 1);
    WHILE (pos! = 0) LOOP
    i: = i + 1;
    Strings (i): = substr(lv_str,1,pos-1);
    lv_str: = substr (lv_str, pos + 1, length (lv_str));
    POS: = instr (lv_str, p_delim, 1, 1);
    IF pos = 0 THEN
    Strings (i + 1): = lv_str;
    END IF;
    END LOOP;

    run immediately "drop table TWG;
    run immediately ' CREATE GLOBAL TEMPORARY table (data_element number) TWG on commit preserve rows ";

    FORALL i in strings.first... Strings.Last
    INSERT INTO VALUES TWG (strings (i));
    commit;

    Update first_tbl set PIN is "XXX" where first_col in (select data_element from TWG);.
    commit;

    END test_proc;

    Published by: cedric b on January 25, 2013 12:59

    Remove the two execute immediate line. They are wrong.

    And then use the table in your code that you created at the beginning. The name is GLT.
    And delete the first commit. This validation would empty the temporary table of GLT.

    You get an error? Or it does not work as expected?

    Also, show how you call the procedure.

    Published by: Sven w. January 25, 2013 14:45

  • SELECT the data inserted into a global temporary Table in a stored proc

    A stored procedure is run from Oracle SQL Developer to insert data into a global temporary table. A SQL (in Oracle SQL Developer) worksheet is open to run a SELECT query to retrieve the data from the temporary table overall which was populated in the stored procedure. No row is returned. I guess it's because the stored procedure and the SELECT statement executed in different sessions.

    Is it possible to run the stored procedure in Oracle SQL Developer and then execute a select statement on the temporary table overall which was filled in the stored procedure by using the same connection so that the data can be extracted?

    I use version 1.5.1 build HAND-5440 of Oracle SQL Developer.

    In a worksheet, do something like

    Start
    insert_proc;
    end;

    Select * from my_temp_table;

    Place the cursor on each statement in turn and Press f9 (where it all began... the end is a single statement.

  • Very slow SELECT * FROM table

    Hello
    could you please help me, that's why execution of
    Select * from myTable very slow (more than an hour and running)?
    Table has 2 GB, BUT the use of the disc is only 5%!

    When I execute select count (*) from myTable, usage is 100% and I have the result in 1 minute...

    Thank you.

    Please see the nets [url http://forums.oracle.com/forums/thread.jspa?messageID=1812597#1812597] when your query takes too long... and [url http://forums.oracle.com/forums/thread.jspa?threadID=863295&tstart=0] HOW TO: post a request for tuning SQL statement - model of accounting. Maybe comment by Sybrand on accounting for the new trace files needs a qualification, as the work through the normal steps of setting before posting the raw trace.

    I think you might have some misconceptions about the work of parallel processing how and what to KEEP. You can also consult the manual of Concepts on when things go in the PGA, and when they go into the CMS and find out how to see the use of the PGA. If you try to load the buffers of the SGA by making a parallel with full table scan, it won't, because this combination uses your PGA and multiblock reads to increase performance - negative in some cases, such as yours.

    In other words, you're [url http://www.doingitwrong.com/wrong/585_munkavedelem.jpg] made wrong.

  • INSERT INTO with SELECT CASE

    Hi all
    I have this problem: Insert Table_A Table_B values... with a derivatives/calculated filed.
    Example of
    INSERT INTO Table_A (id_part, vendtype, origin, proven, desc)
    SELECT id_p, vendt, origin, proven, <calculate/derivated_field_desc>
    FROM Table_B
    The rules for calculating the desc field inserted on Table_A are
    1. IF vendt='V' AND origin='N' AND proven!='04' THEN ---> desc='TRANSFER'
    2. IF vendt='M' AND origin='N' AND proven!='04' THEN ---> desc='IMPORTED'
    3. IF proven='04' THEN ---> desc='BAD'
    So what I use on my INSERT INTO statement < calculate/derivated_field_desc >?
    Can I use a SELECT BOX WHEN block... or only DECODE is a good solution?

    Published by: November 15, 2010 12.51 trebbia

    Two things I noticed: 1. you should remove the "SELECT" before the CASE and 2. There is an incompatibility of single quotation mark (').

  • do a select from table using order by ASC and recover only a range

    Hello
    I have a problem in my program and I want to know the line which is the cause in order to correct the code!

    -There is a line between 19500 and 19600 lines that gives me an error.
    -my program made a NLSSORT (my_field, ' nls_sort = binary "") AS "KEY1".

    so I think that if I do something like that, I get the same order:

    Select * from my_table
    order my CSA my_field
    where the rank number bettween 19500 and 19600

    My problem:
    I have no idea how to do this last part. does anyone know how to do this?
    I was just trying to sort it out and then check out lines up to 19600, but I can't do that because there is no enough space in temp score.


    Thank you.

    Best regards
    Ricardo Tomas
    select col1, col2, col3...
    from (select my_table.*, rownum rn
           from (select * from my_table
                    order by my_field asc
                 ) my_table
          )
    where rn between 19500 and 19600
    

    Note: you must order in a subselect before applying the rownum because the order is usually applied after the right column in a statement pseudo-device select rownum.

  • 2 blocks from the database data insert into the same base table?

    Hello
    I have the C_NEW canvas. On this canvas, elements of 3 blocks are usable by the user.

    1 block NEW_HEAD: 3 Articles say X 1, X 2, X 3
    2 block NEW: record multi say Y1 thru Y10 text fields. Also a scroll bar.
    3 block NEW_ACTION: 6 buttons say B1 to B6 (one of them is N_OK which matches the element in question)

    two NEW, NEW_HEAD blocks are blocks of db and have the same basic so-called BT table when users click on the N_OK (after filling the data in the NEW_HEAD and then NEW block in that order), I need the data between the two the NEW, NEW_HEAD to enter the BT. currently only the NEW data goes to BT. in the BT table fields that correspond to the fields X 1, X 2, X 3 in the NEW_HEAD remains null after clicking on the N_OK button. I put commit_form in the N_OK code, since the blocks are blocks of db (as suggested by the people, it is easier to issue a commit_form that a lot more work in writing my own SQL).

    How can I achieve this?

    Thank you
    Chiru

    There is therefore no N_LC_DMG_ALLOW column in the table, that the block is the result. You must set the property "Section of the database" not for all the elements that are not of the columns in your database table.

    And when an error occurs, then the full treatment stops, so its clear that there is no inserted record.

  • How to open an image inserted into a message from OE

    How can I open a picture inserted in an e-mail?

    You right-click on it and choose Save picture.  After you register, then you can open it as a separate image.
     
    Steve
     
    "Sabre Dave" wrote in message News: 97fd8555-ae72-4c2e-b783-69b04e6cee74...

    How can I open a picture inserted in an e-mail?

  • Select * from TABLE (tst_name_pw.list);

    Windows XP + 10.2.0.1.0 Oracle

    I did tst_name_pw desc and show as below:

    PROCEDURE Argument name default input/output Type
    ------------------------------ ------------------------------ ---------------------------------------------------------- --------- -------
    (FUNCTION) < return value > TABLE LIST unknown


    I have don see the table as tst_name_pw or the list name in the database.
    Anyone it clarify it please?
    Thank you

    Hello

    782150 wrote:
    Windows XP + 10.2.0.1.0 Oracle

    I did tst_name_pw desc and show as below:

    PROCEDURE Argument name default input/output Type
    ------------------------------ ------------------------------ ---------------------------------------------------------- --------- -------
    LIST (FUNCTION) TABLE OF strangers

    I have don see the table as tst_name_pw or the list name in the database.
    Anyone it clarify it please?
    Thank you

    It seems that tst_name_pw is a package, not a table.

  • Oracle 9 error: insert into temp-table collection (nested table)

    Hello everyone

    I have an urgent problem. I have a package which has been developed against 10g but must now be deployed on 9i as well. I don't use 10 g - features and packages compile well on 9.

    Somehow, I get the following runtime error: failed execution: ORA-22905: cannot access the rows of a no nested table item.

    The Code I use to the particular line is

    insert into tmp_report_calculation (select from table (calculations)); *

    tmp_report_calculation is a temporary table and calculations holds a collection type that is a nested table. I do not understand why the error is complaining about "No nested table. Less than 10g everything run took place.

    Can someone help me out here? Furthermore, it is important that I put the results in this temp-table (since I can't use the multiset on Oracle 9)

    concerning
    -Marc

    Try

    insert into tmp_report_calculation (select * from table(cast(calculations as your_collection_type)));
    

    replace"your_collection_type" with your name in the actual collection of course...

  • Error when inserting into a table

    Hello
    I run this insert stmt
    SQL > insert into cntct select * from CUSTSRV_ADMN.cntct_bk1;
    *
    ERROR on line 1:
    ORA-01733: virtual column not allowed here

    This is the structure of the table.

    SQL > cntct desc;
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    CNTCT_KEY NOT NULL NUMBER (10)
    CNTCT_NUM NOT NULL CHAR (12)
    SRC_SYS_DESC NOT NULL VARCHAR2 (5)
    ACTVTY_DT NOT NULL DATE
    CNTCT_TYPE_DESC NOT NULL VARCHAR2 (15)
    CNTCT_INIATR_CD NOT NULL CHAR (1)
    CNTCT_INIATR_DESC NOT NULL VARCHAR2 (10)
    CNTCT_INIATR_NAME NOT NULL VARCHAR2 (30)
    CNTCT_INIATR_PHONE_NUM VARCHAR2
    CNTCT_STUS_CD NOT NULL CHAR (1)
    CNTCT_STUS_DESC NOT NULL VARCHAR2 (10)
    CNTCT_AGE_DAYS_CNT NOT NULL NUMBER 4
    CNTCT_ELPSD_TIME_SEC_CNT NOT NULL NUMBER (10)
    CNTCT_RCVD_DT NOT NULL DATE
    CNTCT_OPEN_DT NOT NULL DATE
    CNTCT_RSLTN_DT NOT NULL DATE
    CNTCT_NEW_IND NOT NULL CHAR (1)
    HIGHST_NMIS_CD NOT NULL NUMBER (1)
    INIATNG_AGENT_KEY NOT NULL NUMBER (5)
    CLSNG_AGENT_KEY NOT NULL NUMBER (5)
    CNTCT_ID NOT NULL VARCHAR2 (20)
    IMG_NUM NOT NULL VARCHAR2 (13)
    PRVDR_NPI NOT NULL VARCHAR2 (10)
    PRVDR_TIN NOT NULL VARCHAR2 (9)
    CNTCT_OPEN_DTIME NOT NULL DATE
    CNTCT_RSLTN_DTIME NOT NULL DATE

    Please notify.

    Kind regards
    Narayan

    The table where you try to insert data, is a table or a view.

    Please check the details of the error.

    ORA-01733: virtual column not allowed here
    Cause: An attempt was made to use an INSERT, UPDATE, or DELETE statement on an expression in a view.
    Action: INSERT, update, or DELETE data in the base tables, instead of the view.

  • Insert into another table through dynamic suite

    Hello


    I need to insert data from one table to the other dynamic thereafter. The reason we use where condition can vary in the select statement. Can someone tell me the logic to use


    the sql statement is like that

    INSERT INTO table1

    SELECT * FROM table2 WHERE condition


    the condition can vary as because it must come forward


    Any ideas will be greatly appreciated


    Thank you
    Martine

    Martine wrote:
    Hello

    I need to insert data from one table to the other dynamic thereafter. The reason we use where condition can vary in the select statement. Can someone tell me the logic to use

    the sql statement is like that

    INSERT INTO table1

    SELECT * FROM table2 WHERE condition

    the condition can vary as because it must come forward

    Any ideas will be greatly appreciated

    Thank you
    Martine

    I advise generally live by using dynamic SQL, because it is difficult to develop, hard to debug, hard to maintain and very difficult to resolve. He peut seem reasonable in the situation you described, but think first about the other possibilities. If you have only two or three variants, it is probably easier to use IF and INSERTs hard-coded logic.

    If you must use dynamic SQL build the SQL text and use EXECUTE IMMEDIATE to do INSERTIONS and SO logical to concatenate the WHERE clause as necessary, something like

      v_text_c := 'insert into my_table(col1)'||chr(13)||
        'select col1'||chr(13)||
        '  from my_table2'||chr(13)'||
      ' where 1 = 1';
      if (whatever) then
        v_text_c := v_text_c||'  and col2 = 'whatever');
    end if;
    

    ' WHERE 1 = 1' is a placeholder for any or any other predicates. Chr (13) is a line break to make the generated SQL code readable appears.

    I find it also useful to create a table with a column CLOB to put the SQL code generated for future reference of error handling.

    Good luck!

Maybe you are looking for