To select and insert

Hello

I am trying to insert a line to another table based on the value of the line of the select statement. Code doesn't seem to work, the pointers?

declare
maxRow integer: = 0;
I PLS_INTEGER: = 0;

Start
-get max rank
Select max (rownum) in the temp maxRow;

-all loop to insert values from table temp2
while I, maxRow loop

Select temp.*, case when gross_qty = 0 then insert into temp2 values (i, customer, condition, 0, qty, 'true', 'false', 'false');
end;
temp where rownum = i;

i: = i + 1; -the loop counter

end loop;
end;

Hello

As Someoneelse said, an SQL INSERT statement will do what you want. There is no need to use the PL/SQL.
If you have reason to do this in PL/SQL, it will be still more efficient to use a single INSERT statement.

You have some of the columns defined in temp3 in regards to the other columns in temp3.
For example, you know the value of qty_used_from_client_qty before you can find the value of short and status.
If you can't figure out how to set all columns in temp3 in terms of columns in temp1 and temp2, or if this would imply losts of nested calculations and repeated, then you can comput some columns in subqueries and use the vlues calculated in Super queries.

The following solution uses two subqueries in this way and produces something close to what you asked:

INSERT INTO temp3
(     rnum
,     c2
,     status
,     gross_qty
,     qty_used_from_client_qty
,     extra
,     short
,     short_qty
)
WITH     gq     AS
(     -- Begin sub-query gq to compute gross_qty, qty
     SELECT     NVL (t1.client,          t2.client)     AS client
     ,     NVL (t1.gross_qty,     0)          AS gross_qty
     ,     NVL (t2.qty,          0)          AS qty
     FROM               temp1     t1
     FULL OUTER JOIN          temp2     t2     ON t1.client     = t2.client
)     -- End sub-query gq to compute gross_qty, qty
,     qufcq     AS
(     -- Begin sub-query qufcq to compute qty_used_from_client_qty
     SELECT     client
     ,     gross_qty
     ,     qty
,     CASE
          WHEN     gross_qty     IN (0, qty)     THEN     qty
          WHEN     qty          < 0          THEN     0
          WHEN     gross_qty     < qty          THEN     gross_qty
     END          AS qty_used_from_client_qty
,     CASE
          WHEN     gross_qty < qty     THEN     'TRUE'
                         ELSE     'FALSE'
     END          AS extra
     FROM     gq
)     -- End sub-query qufcq to compute qty_used_from_client_qty
SELECT     0          -- row_num
,     client          -- c2
,     CASE
          WHEN     gross_qty               = 0     THEN     'Client Table'
          WHEN     qty_used_from_client_qty     IS NULL     THEN     'Manager Table'
                                        ELSE     'Both Tables'
     END               -- status
,     gross_qty
,     qty_used_from_client_qty
,     extra
,     CASE
          WHEN     gross_qty     >= qty_used_from_client_qty
           AND     gross_qty     != 0          THEN     'TRUE'
                                   ELSE     'FALSE'
     END               -- short
,     GREATEST     ( gross_qty - qty
               , 0
               )     -- short_qty
FROM     qufcq;

The above query produces the following results:

.                               QTY_USED
                       GROSS_     _FROM_             SHORT
RNUM C2  STATUS           QTY CLIENT_QTY EXTRA SHORT  _QTY
---- --- ------------- ------ ---------- ----- ----- -----
   0 AAA Both Tables        5          5 TRUE  TRUE      0

   0 AAA Both Tables        3          3 TRUE  TRUE      0

   0 BBB Both Tables        3          3 FALSE TRUE      0

   0 CCC Client Table       0          2 TRUE  FALSE     0

   0 YYY Manager Table      1            FALSE FALSE     1

This differs from the desired output you posted in these ways:
(a) you did not how the ROWNUM column is derived. (ROWNUM is a bad name for a column, because it is a reserved word. I used rnum instead.)
(b) I do not see you the value qty_used_from_client_qty = 2 on the second row. According to your definitions, this column must always be either 0, temp2.qty or temp3.gross_qty, so the choices for this line should be 0, 7 and 3.
(c) on the same line, I calculated short_qty = 0 (instead of 1, as you have it posted). This problem may be related to (b)
(d) more often that otherwise, the additional and short columns, I calculated are are different from what you have posted.

I don't know if I've misunderstood something, or you typed something wrong.
If you can't find how to get the results you want, check again the sample data and the rules that you have posted.
If there is still a gap, highlight where the query above is production of erroneous results and explain the relevant rules in a different way.

Furthermore, you have not really to create tables temp1 and temp2 just to produce temp3. You can make temp1 and temp2 subqueries of the INSERT statement.

Tags: Database

Similar Questions

  • Select and insert into the code of people

    (1) I have the sql statement to follow, I want to select ROLEUSER, ROLENAME and insert it in my new journal The Recode, how to handle this?
      
    select ROLEUSER,ROLENAME from roleuserTab where roleuser in( 
    select oprid from student where stuId ='KU0056')
    and (rolename) in
    (select rolename from student where roleuser in( 
    select oprid from student where stuID ='KU0056')
    minus
    select rolename from roleuserTab  
     where roleuser = 'SupperIT_user')

    If I understand you correctly, you have a variable in PeopleCode of type Date and you want to assign a value to this variable.

    If the State save the the_AET field. Z_LEFT_DEPT_ON is a type of date, you can assign
    & resultvalue3 = the_AET. Z_LEFT_DEPT_ON

    If the State save the the_AET field. Z_LEFT_DEPT_ON is of type number and value is in the format YYYYMMDD, you can assign
    & resultvalue3 = date (the_AET. Z_LEFT_DEPT_ON)

    If the State save the the_AET field. Z_LEFT_DEPT_ON is a string and the value is in the format YYYYMMDD, you can assign
    & resultvalue3 = date (value (the_AET. Z_LEFT_DEPT_ON))

    If the State save the the_AET field. Z_LEFT_DEPT_ON is of type string and value is not in YYYYMMDD format, you can use the following instructions
    Date3 (year, month, day)

    Do not use % DateIn in PeopleCode to assign values to variables, only in SQL
    PeopleBooks > Enterprise PeopleTools 8.51 PeopleBook: PeopleCode language reference > Meta-SQL elements
    % DateIn
    Syntax

    %DateIn(DT)
    Description

    The variable % of meta-SQL DateIn develops in SQL syntax specific to the platform for the date. % Use DateIn every time that a literal date or the link Date variable is used in a comparison in the Where clause of a statement Select or Update, or when a Date value is passed in an Insert statement.

    you wrote

    so, how I decide when I should help SQLExec or CreateSQL? With CreateSQL is the only building an SQL statement and assign values to the command prompt.
    You can no longer use the SQL built in & SQL. Search for loops or & SQL. Run the toe run SQL
    PeopleBooks > Enterprise PeopleTools 8.51 PeopleBook: PeopleCode QAnywhere > class SQL

    PeopleBooks > Enterprise PeopleTools 8.51 PeopleBook: PeopleCode language reference > built-in functions PeopleCode
    Use the SQLExec function to execute a SQL command from within a PeopleCode program by passing a SQL command string. The SQL command bypasses the processor component and interacts directly with the database server. If you want to delete, insert, or update a single record, use the corresponding PeopleCode record object method.

    If you want to delete, insert, or update a series of records, all of the same type, use the CreateSQL or GetSQL functions, then the method of the class to execute SQL.

    As you can see that all the information in PeopleBooks, you needn't wait for answers on the forums when the information is available.
    http://docs.Oracle.com/CD/E17566_01/epm91pbr0/Eng/psbooks/psft_homepage.htm

  • Change the value of column select and insert different

    Hi all

    I've written a procedure where I am selecting values in other tables and inserting into a new table. The code is below
     
    If you see line 54 in the code, you will find the combined_bu_code is comes from a procedure and the value of BU is stored in prod. Table SEM_BACKLOG_LOG. I need to check, if the combined_bu_code came as PWR then insert as table BACKLOG_OTD_NEW POWER not as PWR.

    You are looking for assistance on this. Thanks in advance

    Concerning

    Published by: User_Apex on June 23, 2011 03:03

    Published by: User_Apex on June 23, 2011 03:53
    DECODE(SMTC_OTD_CHART.get_combined_bu_code(a.BU), 'PWR', 'POWER', SMTC_OTD_CHART.get_combined_bu_code(a.BU)) COMBINED_BU_CODE
    

    Kind regards
    Richard

    -----
    blog: http://blog.warp11.nl
    Twitter: @rhjmartens
    If you answer this question, please mark the thread as closed and give points where won...

  • Cursor to select and insert data

    Hello

    I'm not very familiar with the things of cursor. I need to write a simple slider that will select rows in a database table and then insert into a database table B. And the structure of the table both is the same.

    And after installation, it must change the status of a table in a database. Please help me write a slider down.

    Kind regards

    Oh, I don't understand the performance))) but if you need then procedure with the post office

    create or replace procedure MyProc is

    Start

    insert into b@BLINK

    Select * from where a st =

    update a set st = where m =

    commit;

    end;

    () DBMS_SCHEDULER.create_job

    job_name-online "MySuperJob."

    job_type-online 'procedure ',.

    job_action-online "MyProc"

    start_date-online to_date ('28.10.2013 01:00 ',' dd/mm/yyyy hh24:mi:ss'),

    repeat_interval => ' FREQ = minutely; range = 3',

    End_date => NULL,

    -Online TRUE, enabled

    Comments => ");

    ----

    Ramin Hashimzade

  • SQL SELECT and insert

    Is it possible to have a sql that goes sth like this in PL/SQL?
    select name,date, age from CUSTOMER then insert into temp_cust values (name,date,age)
    Lets assume that the CUSTOMER table contains 10 or more records. Is there another way to use the slider?

    If you're looking to insert the value into the CUSTOMER table in TEMP_CUST

    You can simply

    insert into temp_cust(name,date,age) select name,date, age from CUSTOMER
    
  • Who is fastest on the index select or insert?

    Who is fastest on the index select or insert?

    SELECT and insert are totally different operation. And I don't understand what you're trying to ask.

    What do you mean by fast on index?

    Insert becomes generally slow if you have indexes. This is because the db has to do more work, write the data and index.

    Select can be much faster if good indicator are in place. which can lead to an analysis of index and avoide a full table scan.

    Is that what you are looking for?

  • What is the difference in FORALL and INSERT IN SELECT()

    Hello

    I know WHAT FORALL bulk insert/update/delete.

    My question is

    Select Insert in emp_temp from EMP; *
    also works as bulk collect the right?

    so, what is the difference and what is the best.

    As I'm feeling forall complications as many restrictions is here.

    Thank you
    Vinod

    FORALL is PL/SQL and "INSERT..." SELECT... "is pure SQL.

    You must use SQL whenever possible. When you have complicated business logic and TABLES are possible solutions only you can go for FORALL for better performance.

  • Select values from the db1 table and insert into the DB2 table

    Hello

    I have three databases oracle running in three different machines. their ip address is different. among the DB can access databases. (means am able to select values and insert values into tables individually.)

    I need to extract data from the DB1 table (ip say DB1 is 10.10.10.10 and the user is DB1user and the table is DB1user_table) and insert the values into DB2 table (say ip DB2 is 11.11.11.11 and the user is DB2user and table DB2user_table) of DB3 that is to have access to the two IPs DB.

    How do I do this

    Edited by: Aemunathan on February 10, 2010 23:12

    Depending on the amount of data must be moved between DB1 and DB2, and the frequency at which this should happen, you might consider the SQL * COPY more control. I think it's very useful for one-off tasks little, so I can live within its limits of the data type. More http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/apb.htm#i641251.

    Change some parameter of sqlplus session are almost mandatory in order to get decent transfer rates. Tuning ARRAYSIZE and COPYCOMMIT can make a huge difference in flow. LONG change may be necessary, too, depending on your data. The documentation offers these notes on use:

    To activate the copy of data between Oracle and databases non-Oracle, NUMBER of columns is replaced by DECIMAL columns in the destination table. Therefore, if you are copying between Oracle databases, a NUMBER column with no precision will become a DECIMAL column (38). When copying between Oracle databases, you must use SQL commands (CREATE TABLE AS and INSERTION), or you must make sure that your columns have a specified precision.

    SQL * the VALUE LONGER variable limits the length of the LONG column you are copying. If all LONG columns contain data exceeds the value of LONG, COPY truncates the data.

    SQL * Plus performs a validation at the end of each successful COPY. If you set the SQL * variable more COPYCOMMIT DEFINED to a value positive n, SQL * Plus performs a validation after copying all lots n of records. The SQL * Plus ARRAYSIZE variable SET determines the size of a batch.

    Some operating environments require that the service names be placed between double quotes.

    From a SQL * Plus term on DB3, can resemble the command to move all content from my_table in DB1 to the same table in DB2

    COPY from user1/pass1@DB1 to user2/pass2@DB2 -
    INSERT INTO my_table -
    USING select * from my_table
    

    Note the SQL code * more line-continuation character ' - '. It is used to escape the newline character in a SQL * Plus command if you do not have to type all on one line. I use it all the time with this command, but I can't locate the documentation on that right now. Maybe someone else can put their finger on it.

    There are other ways to accomplish what the command copy and it is not without its quirks and limitations, but I find that there is usefulness in an Oracle Toolbox.

  • Create a temporary table and insert using a select statement

    Hello

    I tried to create a temporary table and insert it by using the value in a select statement. Please see below the code

    ---
    CREATE a TEMPORARY TABLE GLOBAL Temp_Test
    (
    DATE OF DAY_FUTURE
    )
    AS
    SELECT TO_DATE (SYSDATE + ROWNUM, 'DD-MON-YY')
    DUAL CONNECT BY ROWNUM FROM < = 14)
    ---

    As soon as I run the script, the error message indicates the following:
    --

    Error from the 1 in the command line:
    CREATE a TEMPORARY TABLE GLOBAL Temp_Test
    (
    DATE OF DAY_FUTURE
    )
    ONLY select TO_DATE (sysdate + rownum, 'DD-MON-YY')
    Double connect rownum < = 14)

    Error in the command line: 2 column: 1
    Error report:
    SQL error: ORA-01773: cannot specify the types of data in this TABLE to CREATE column
    01773 00000 - 'cannot specify the types of column data in this TABLE to CREATE"
    * Cause:
    * Action:
    --


    What seems the problem? I already have the data type such as TO_DATE on my select statement.

    Any help would be appreciated

    Thank you
    SQL> CREATE GLOBAL TEMPORARY TABLE Temp_Test
      2  (
      3  DAY_FUTURE
      4  ) on commit preserve rows
      5  AS
      6  SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY')
      7  FROM DUAL CONNECT BY ROWNUM <= 14
      8  /
    
    Table created.
    
    SQL> select count(*)
      2    from temp_test
      3  /
    
      COUNT(*)
    ----------
            14
    
  • Going crazy trying to select and move multiple points of tempo

    I tried to move a whole bunch of tempo of a bar points to a spot 4 bars later in my project. First time this... For the life of me I can't figure out what I'm doing wrong as I * try * follow the steps here: Logic Pro X: move and copy points of tempo

    Here's a quick screencast to choose me (while holding the CONTROL key) and then drag (hold down CTRL key):

    https://youtu.be/HpLHQbV4y9U

    (The editor let me not insert a video this time so I downloaded on YouTube instead.)

    I tried dragging dragging the first point of tempo, dragging from the last point of tempo, a place randomly in the Middle the selected points. I also tried now the shift and CONTROL simultaneously select and drag when he did not work on the other hand, only because the instructions mentioned the option to SHIFT + click in the selection. Finally, I tried the same thing while now the SHIFT key instead of CONTROL (don't wait not that it works of course because the instructions didn't say to do, but I tried the way described several times and she didn't).

    Get these points of tempo settles is the last detail in a huge song that ended the case

    There must be some small detail that I forgot the instructions. Any suggestions? Thanks in advance!

    Use the smudge tool to enter the automation of tempo and move it left or right...

  • Make CD covers and inserts for boxes

    Hello
    I want to a CD and insert for a green jacket. I have the images and the ready text, currently in a mixture of PowerPoint and Word. What is the best way to create something that looks good and is the right size, please? My group has just completed recording a CD and we want to give something suitable to the company which will build on the CD.
    Thank you
    John

    Hello

    Be sure to ask on the forums of music you can find.

    The good news is that there are a lot of good and hard to keep track of them.

    Freeware http://www.snapfiles.com/Freeware/system/fwprintertools.html

    Google for Freeware
    http://www.google.com/search?hl=en&q=Print+Jewel+case+Cover+freeware&aq=f&aqi=&OQ=

    Google for commercial programs
    http://www.google.com/search?hl=en&source=HP&q=Print+Jewel+case+Cover&aq=f&aqi=G1&OQ=

    Acousitca - commercial program
    http://www.Acoustica.com/CD-Label-Maker/

    Good Forum to ask
    http://Club.myce.com/F123/

    ==============================

    If necessary selections:

    WINDOWS MEDIA PLAYER PLAYLIST PRINT
    http://www.footballchance.com/WMPplaylist.shtm

    How do I print a playlist in Media Player 11 - it comes to the use of the foregoing
    http://www.ehow.com/how_5614381_print-playlist-Media-Player-11.html

    Printing of playlists
    http://Askville.Amazon.com/SimilarQuestions.do?req=Windows-Media-Player-11---print-listing-artists-albums-library

    ==============================================

    This free program does not print playlists but it offers control over printing file lists.

    No longer fumbling with my computer or Windows Explorer, we wish you could print information
    all of your files. Directory of Karen printer can print the name of every file on a disk, as well as the file
    size, date and time of last modification, and attributes (read-only, hidden, system and Archive)! And
    now, the list of files can be sorted by name, size, date created, date last modified, or last access date.
    http://www.KarenWare.com/PowerTools/ptdirprn.asp

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • I converted a clip video .mov .avi and inserted in Windows Movie Maker, but it's only playing as sound and no video

    Original title: Windows Media Player
    I converted a clip video .mov .avi and inserted in Windows Movie Maker, but it's only playing as sound and no video, why?

    There may be some compatibility issues with .avi files...
    try to convert the .mov file to .wmv format before
    import into Movie Maker.

    There are many programs that can do conversions...
    The following freeware is an example...:

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    Format Factory
    http://www.videohelp.com/tools/Format_Factory
    (the 'direct link' is faster)
    (the file you want to download is: > FFSetup260.zip<>
    (FWIW... installation..., you can uncheck
    ('all' boxes on the last screen)

    First, you will need to decompress the file or just open the
    Drag FFSetup260.exe out of the folder
    and drop it on your desktop. To install left click.

    Next, after the download and installation of Format
    Factory... you can open the program and
    left click on the toolbar, the "Option" button and
    "Select an output folder to" / apply / OK.
    (this is where you find your files after they)
    are converted)

    Drag and drop your clips on the main screen .mov...

    Select "all to WMV" / OK...

    Click on... Beginning... in the toolbar...

    That should do it...

    Good luck...

  • Difference in performance between the CTA and INSERT / * + APPEND * / IN

    Hi all

    I have a question about the ETG and "Insert / * + Append * / Into" statements.

    Suite deal, I have a question that I did not understand the difference in operating times EXADATA.

    The two tables of selection (g02_f01 and g02_f02) have not any partition. But I could partition tables with the method of partition by column "ip_id" hash and I tried to run the same query with partition tables. Change anything in execution times.

    I executed plan gather statistics for all tables. The two paintings were 13.176.888 records. The two arrays have same "ip_id' unique columns. I want to combine these tables into a single table.

    First request:

    Insert / * + append parallel (a, 16) * / in dg.tiz_irdm_g02_cc one

    (ip_id, process_date,...)

    Select / * + parallel (a, 16) parallel (16B) * / *.

    tgarstg.tst_irdm_g02_f01 a.,

    tgarstg.tst_irdm_g02_f02 b

    where a.ip_id = b.ip_id


    Elapsed = > 45: 00 minutes


    Second request:

    create table dg.tiz_irdm_g02_cc nologging parallel 16 compress for than query

    Select / * + parallel (a, 16) (b, 16) parallel * / *.

    tgarstg.tst_irdm_g02_f01 a.,

    tgarstg.tst_irdm_g02_f02 b

    where a.ip_id = b.ip_id

    Elapsed = > 04:00 minutes


    Execution plans are:


    1. Enter the statement execution Plan:

    Hash value of plan: 3814019933

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

    | ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU). Time |    TQ | IN-OUT | PQ Distrib.

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

    |   0 | INSERT STATEMENT.                  |    13 M |    36G |       |   127K (1) | 00:00:05 |        |      |            |

    |   1.  LOAD SELECT ACE | TIZ_IRDM_G02_CC |       |       |       |            |          |        |      |            |

    |   2.   COORDINATOR OF PX |                  |       |       |       |            |          |        |      |            |

    |   5:    PX SEND QC (RANDOM). : TQ10002 |    13 M |    36G |       |   127K (1) | 00:00:05 |  Q1, 02 | P > S | QC (RAND) |

    |*  4 |     IN THE BUFFER HASH JOIN |                  |    13 M |    36G |   921 M |   127K (1) | 00:00:05 |  Q1, 02 | SVCP |            |

    |   3:      RECEIVE PX |                  |    13 M |    14G |       |  5732 (5) | 00:00:01 |  Q1, 02 | SVCP |            |

    |   6.       PX SEND HASH | : TQ10000 |    13 M |    14G |       |  5732 (5) | 00:00:01 |  Q1 00 | P > P | HASH |

    |   7.        ITERATOR BLOCK PX |                  |    13 M |    14G |       |  5732 (5) | 00:00:01 |  Q1 00 | ISSUE |            |

    |   8.         STORE TABLE FULL ACCESS | TST_IRDM_G02_F02 |    13 M |    14G |       |  5732 (5) | 00:00:01 |  Q1 00 | SVCP |            |

    |   9.      RECEIVE PX |                  |    13 M |    21G |       | 18353 (3) | 00:00:01 |  Q1, 02 | SVCP |            |

    |  10.       PX SEND HASH | : TQ10001 |    13 M |    21G |       | 18353 (3) | 00:00:01 |  Q1, 01 | P > P | HASH |

    |  11.        ITERATOR BLOCK PX |                  |    13 M |    21G |       | 18353 (3) | 00:00:01 |  Q1, 01 | ISSUE |            |

    |  12.         STORE TABLE FULL ACCESS | TST_IRDM_G02_F01 |    13 M |    21G |       | 18353 (3) | 00:00:01 |  Q1, 01 | SVCP |            |

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

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

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

    4 - access("AIRDM_G02_F01".") IP_ID '= 'AIRDM_G02_F02'.' IP_ID")

    2 - DEC execution Plan:

    Hash value of plan: 3613570869

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

    | ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU). Time |    TQ | IN-OUT | PQ Distrib.

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

    |   0 | CREATE TABLE STATEMENT.                  |    13 M |    36G |       |   397K (1) | 00:00:14 |        |      |            |

    |   1.  COORDINATOR OF PX |                  |       |       |       |            |          |        |      |            |

    |   2.   PX SEND QC (RANDOM). : TQ10002 |    13 M |    36G |       |   255K (1) | 00:00:09 |  Q1, 02 | P > S | QC (RAND) |

    |   3.    LOAD SELECT ACE | TIZ_IRDM_G02_CC |       |       |       |            |          |  Q1, 02 | SVCP |            |

    |*  4 |     HASH JOIN |                  |    13 M |    36G |  1842M |   255K (1) | 00:00:09 |  Q1, 02 | SVCP |            |

    |   5.      RECEIVE PX |                  |    13 M |    14G |       | 11465 (5) | 00:00:01 |  Q1, 02 | SVCP |            |

    |   6.       PX SEND HASH | : TQ10000 |    13 M |    14G |       | 11465 (5) | 00:00:01 |  Q1 00 | P > P | HASH |

    |   7.        ITERATOR BLOCK PX |                  |    13 M |    14G |       | 11465 (5) | 00:00:01 |  Q1 00 | ISSUE |            |

    |   8.         STORE TABLE FULL ACCESS | TST_IRDM_G02_F02 |    13 M |    14G |       | 11465 (5) | 00:00:01 |  Q1 00 | SVCP |            |

    |   9.      RECEIVE PX |                  |    13 M |    21G |       | 36706 (3) | 00:00:02 |  Q1, 02 | SVCP |            |

    |  10.       PX SEND HASH | : TQ10001 |    13 M |    21G |       | 36706 (3) | 00:00:02 |  Q1, 01 | P > P | HASH |

    |  11.        ITERATOR BLOCK PX |                  |    13 M |    21G |       | 36706 (3) | 00:00:02 |  Q1, 01 | ISSUE |            |

    |  12.         STORE TABLE FULL ACCESS | TST_IRDM_G02_F01 |    13 M |    21G |       | 36706 (3) | 00:00:02 |  Q1, 01 | SVCP |            |

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

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

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

    4 - access("AIRDM_G02_F01".") IP_ID '= 'AIRDM_G02_F02'.' IP_ID")

    Oracle version:

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

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    Notice how this additional distribution has disappeared from the non-partitioned table.

    I think that with the partitioned table that oracle has tried to balance the number of slaves against the number of scores he expected to use and decided to distribute the data to get a 'fair sharing' workload, but had not authorized for the side effects of the buffer hash join which was to appear and extra messaging for distribution.

    You could try the indicator pq_distribute() for the insert to tell Oracle that he should not disrtibute like that. for example, based on your original code:

    Insert / * + append pq_distribute parallel (a, 16) (a zero) * / in dg.tiz_irdm_g02_cc one...

    This can give you the performance you want with the partitioned table, but check what it does to the space allocation that it can introduce a large number (16) of extensions by segment that are not completely filled and therefore be rather waste of space.

    Concerning

    Jonathan Lewis

  • Read the BLOB and insert data into a table

    Hi all

    Let us examine below on Oracle DB 12 c:

    create table xx_test3 (c blob);
    
    insert into xx_test3 (c) values (utl_raw.cast_to_raw(
    'azertyuiop,qsdfghjklm,wxcvbn'));
    
    
    create table xx_target (col1 varchar2(50));
    
    
    
    

    Can someone guide me how to read the data and insert it into the xx_target table?

    Necessary result is:

    
    select * from xx_target;
    
    
    COL1                                              
    
    --------------------------------------------------
    azertyuiop                                        
    qsdfghjklm                                        
    wxcvbn                                            
    
    3 rows selected.
    
    
    
    
    

    Thanks in advance,

    Stoyanov.

    insert into xx_target (col1)

    with the data as)

    Select utl_raw.cast_to_varchar2 (dbms_lob.substr (c, 32000, 1)) CBC

    of xx_test3

    )

    Select regexp_substr (CBC, ' [^,] +', 1, level)

    from the data

    connect by level<= regexp_count(src,="" ',')="" +="">

  • Parse XML and insert into the table Oracel

    Hi all

    I have an XML document, I need to analyze and take the respective tag data and inserting it into another table.

    This is the XML code that I have.

    " < convertTo xsi: schemaLocation =" https://xecdapi.XE.com/schema/v1/convertTo.xsd "> "

    < terms > http://www.XE.com/privacy.php < / terms >

    < privacy > http://www.XE.com/legal/DFS.php < / privacy >

    < to > < /pour > USD

    < amount > 1.0 < / amount >

    < timestamp > 2015-10-25T 23: 00:00Z < / timestamp >

    < from >

    rate <>

    < currency > EUR < / currency >

    < e > 0.9075541422 < / mid >

    < / rates >

    rate <>

    INR < currency > < / currency >

    < e > 65.0313451105 < / mid >

    < / rates >

    rate <>

    < currency > CAD < / currency >

    < e > 1.3167560135 < / mid >

    < / rates >

    rate <>

    < currency > GBP < / currency >

    < e > 0.6528693249 < / mid >

    < / rates >

    < / from >

    < / convertTo >


    Here is the code I use to analyze the values

    DECLARE

    XMLType x: = XMLType)

    ' ' < convertTo xsi: schemaLocation = " https://xecdapi.XE.com/schema/v1/convertTo.xsd "> "

    < terms > http://www.XE.com/privacy.php < / terms >

    < privacy > http://www.XE.com/legal/DFS.php < / privacy >

    < to > < /pour > USD

    < amount > 1.0 < / amount >

    < timestamp > 2015-10-25T 23: 00:00Z < / timestamp >

    < from >

    rate <>

    < currency > EUR < / currency >

    < e > 0.9075541422 < / mid >

    < / rates >

    rate <>

    INR < currency > < / currency >

    < e > 65.0313451105 < / mid >

    < / rates >

    rate <>

    < currency > CAD < / currency >

    < e > 1.3167560135 < / mid >

    < / rates >

    rate <>

    < currency > GBP < / currency >

    < e > 0.6528693249 < / mid >

    < / rates >

    < / from >

    < / convertTo > '

    );

    BEGIN

    FOR r IN

    (

    SELECT

    Name of the AS ExtractValue (Value (p),'/ rate/currency/text () ')

    -, ExtractValue (value (p), '/ Row/Address/State/Text ()') State

    -, ExtractValue (value (p), '/ Row/Address/City/Text ()') city

    Of

    TABLE (XMLSequence (Extract(x,'convertTo/from/rate'))) p

    )

    LOOP

    -do what you want with r.name, r.state, r.city

    dbms_output.put_line ('Name' | r.Name);

    END LOOP;

    END;

    I get the error message below

    Error report:

    ORA-31011: XML parsing failed

    ORA-19202: an error has occurred in the processing of XML

    LPX-00234: the 'xsi' namespace prefix is not declared

    Error on line 1

    ORA-06512: at "SYS." XMLTYPE", line 310

    ORA-06512: at line 2

    31011 00000 - "XML parsing failed"

    * Cause: XML parser returned an error trying to parse the document.

    * Action: Check whether the document to parse is valid.

    Any help on how to fix this would be really useful.

    Appreciate your time and your help.

    Thank you

    Olivier

    Have you even tried to do what we have suggested?

    SQL > ed
    A written file afiedt.buf

    1 with t as (select xmltype ('))
    "" 2 http://xecdapi.xe.com "xmlns: xsi ="http://www.w3.org/2001/XMLSchema-instance"" xsi: schemaLocation = "https://xecdapi.xe.com/schema/v1/convertTo.xsd" > ""
    3 http://www.xe.com/privacy.php
    4 http://www.xe.com/legal/dfs.php
    5 USD
    6    1.0
    7 2015-10 - 25 T 23: 00:00Z
    8
    9
    10 EUROS
    11 0.9075541422
    12

    13

    14
    ") in XML of the double)"
    15-
    16 end of test data
    17-
    18 select x.*
    19 t
    20, xmltable (xmlnamespaces ("http://www.w3.org/2001/XMLSchema-instance" as "xsi", default 'http://xecdapi.xe.com'),)
    21 ' / convertTo/of/rate.
    22 passage t.xml
    path of VARCHAR2 (3) currency 23 columns '. / currency '
    24, half-way number '. / mid'
    25*                ) x
    SQL > /.
    HEART MI
    --- ----------
    EUR.907554142

    1 selected line.

Maybe you are looking for