Update or merge it with the return data

Hello, I want to do an update in a single statement, and select (I want to get the data and update a field in one of the tables involved with a timestamp), I tried this:

merge into table t

using (SELECT ... a long and complex select...) e

on (e.ID = t.ID)

When matched then

update the value t.ts = systimestamp

e return

It does not work because his return does not seem possible with the merger, he did the update but I get no data...

With an update, I tried:

Update

(

SELECT...) e

Aliens set = systimestamp

And I get ORA-01779: cannont change a column that maps to a table of key-preserver nonkey.

The select is complex with many paintings and selects involved and more than 20 KB of text only select... and this isn't mine so I want a solution that does not need to change the internal selection if possible.

Any ideas? Sorry for my limited knowledge of sql :-(

No, you did not read what I said.  The RETURNING clause allows you to capture the details of the update table.  You may not have the details of the complex query that you use to determine the return lines.  There is no way in SQL to a single statement that updates a table and queries data from other tables at the same time.

The best you're going to manage is to update the data, turning the ID (or regardless of the primary key is appropriate) and then query the query data complex where once again the ID in your collection.  However, it's really messy.  What US the real purpose of all this?

Tags: Database

Similar Questions

  • Until the latest update when the AutoComplete bar has been selected, he "went" no other by clicking. I must now click the refresh arrow. It won't work even with the return. How can I operate the old way easier?

    Until the latest update when the url I wanted in the address bar of AutoComplete has been selected, it "accompanies" no more further by clicking on. I must now click the refresh arrow. It won't work even with the return. How can I operate the old way easier?

    You can disable this extension in tools > Modules > Extensions and close and restart Firefox normally.

  • Insert/update the column with the clob data type

    Hi all

    ORCL Version: 11g.

    I have a table with the clob data type.

    Test12

    (col1 clob);

    I'm trying to insert/update to update the column with more than 4000 characters.

    But due to the limitation of tank 4000, I could not Insert/Update.

    Need your help in resolving this issue.

    THX

    Rod.

    The limit of 4000 characters is incorrect.  That pertains only to the varchar2 data type.  A clob can hold more than 4 G.

    Here is an example that shows how to insert it, I found...

    Otherwise, here is a way 'dirty' to do.

    insert into your_table (COLA, COLB)

    values

    (PRIMARY_KEY, PART 1 OF DATA)

    ;

    Update your_table

    Define COLB = COLB | PART 2 OF BIG DATA

    where COLA = PRIMARY_KEY;

    Update your_table

    Define COLB = COLB | PART 3 OF BIG DATA

    where COLA = PRIMARY_KEY;

    .. and so on...

    I don't know that I personally recommend the second style...  But he could do the job.

  • sql Update query after matching with the string

    I am trying to reach the query that updates a table column with the value of the other table, after that he finds an exact match.

    So here's the table data and sample to create.
    create table code1 
    (
        codeid number,
        codedesc varchar2(60)
    );
    
    Insert into code1 values ( 1,'R1 CONTRACTS');
    
    Insert into code1 values ( 2,'R2 CONTRACTS');
    
    Insert into code1 values ( 3,'R3 CONTRACTS');
    
    Insert into code1 values ( 4,'R5 CONTRACTS');
    
    Insert into code1 values ( 5,'R9 CONTRACTS');
    
    Insert into code1 values ( 6,'R10 CONTRACTS');
    
    create table table1 
    (   
        tablekey number,
        prefix  varchar2(25),
        codedesc    varchar2(60)
    );
    
    Insert into table1(tablekey,prefix) values (1,'1001PAC');
    
    Insert into table1(tablekey,prefix) values (2,'1001MXT');
    
    Insert into table1(tablekey,prefix) values (3,'1002PAE');
    
    Insert into table1(tablekey,prefix) values (4,'1003PCS');
    
    Insert into table1(tablekey,prefix) values (5,'1004BDX');
    
    Insert into table1(tablekey,prefix) values (6,'1005PAC');
    
    Insert into table1(tablekey,prefix) values (7,'1006PAC');
    
    Insert into table1(tablekey,prefix) values (8,'1007LDR');
    
    Insert into table1(tablekey,prefix) values (9,'1009LCR');
    
    Insert into table1(tablekey,prefix) values (10,'1010LBR');
    
    Insert into table1(tablekey,prefix) values (11,'ABCDEF');
    I'm writing a query that would update the value of column - codedesc (currently Null) of the table1 table: after it is a string of column - table code1 codedesc.

    The logic for the match is, - take - 2nd column of table-codedesc code value and get 2 characters. For example, when the string is - R1 CONTRACTS, the string will be 1. (Select substr ("R1 CONTRACTS, 2, 2) of the double). -Output will be 1.

    Now,.
    Look in table 1 for the 3rd position of the prefix that corresponds to the string returned by the query above. So, if the prefix is '1001PAC', it should look for 2 value of figures from the 3rd position. So, in this case it will be 01. Digitally 01 and 1 are equal, then the match is found for this line in the table1 table, so we will need to update the value of the column codedesc with the "contracts of R1.
        tablekey,    prefix            codedesc    
    ---------- ------------------------------------------------------------
    
          1               1001PAC     R1 CONTRACTS    -- Needs to be update with this value. 
          2               1001MXT     R1 CONTRACTS
          3               1002PAE      R2 CONTRACTS
    ...
          11             ABCDEF                                --Null ( No Need to update when no match found).
    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Appreciate your help.

    Hello

    You want to avoid TO_NUMBER, given that will cause an error if even a line has a number no (except space) in the wrong place.
    Use RTRIM to remove extra spaces at the end of the match_key and LPAD to add '0', if necessary, at the beginning:

    MERGE INTO     table1          dst
    USING   (
              SELECT  LPAD ( RTRIM ( SUBSTR ( codedesc
                                     , 2
                                   , 2
                                   )
                              )
                         , 2
                         , '0'
                         )          AS match_key
              ,     codedesc
              FROM     code1
         )               src
    ON     (src.match_key     = SUBSTR ( dst.prefix
                           , 3
                         , 2
                         )
         )
    WHEN MATCHED THEN UPDATE
         SET     dst.codedesc     = src.codedesc
    ;
    

    Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

  • Using DBMS_DATAPUMP with the LONG data type

    I have a procedure below that calls the DBMS_DATAPUMP procedure using a REMOTE_LINK move a schema of one database to another. However, some tables in this schema have columns with the data type of LONG. And when I run it I get an error saying that you cannot move the data with the LONG data type using a REMOTE CONNECTION. So no data in these specific tables gets flying over.

    Does anyone else have this problem? If so, do you have a work around? I tried to add a CLOB column in my table and affecting the new CLOB equal THROUGHOUT, but I couldn't get that to not work either... even when I tried to use a TO_LOB. If I could get that pass, then I could just slide ALONG, the schema, and then re-create the LONG column on the opposite side.

    Here is my procedure...



    DECLARE
    / * IMPORT/EXPORT VARIABLES * /.
    v_dp_job_handle NUMBER;          -The handful of job data pump
    v_count NUMBER;          -Index of the loop
    v_percent_done NUMBER;          -Percentage of job complete
    v_job_state VARCHAR2 (30);     -To keep track of job status
    v_message KU$ _LOGENTRY;     -For error messages and work in PROGRESS
    v_job_status KU$ _JOBSTATUS;     -The State of the work of get_status
    v_status KU$ _STATUS;     -The status returned by get_status object
    v_logfile NUMBER;
    T_DATE VARCHAR2 (13).
    v_source_server_name VARCHAR2 (50);
    v_destination_server_name VARCHAR2 (50);

    BEGIN
    v_project: = 'TEST ';
    T_DATE: = TO_CHAR (SYSDATE, 'MMDDYYYY_HHMI');
    v_source_server_name: = 'TEST_DB ';

    v_dp_job_handle: = DBMS_DATAPUMP. OPEN)
    OPERATION = > "IMPORT."
    JOB_MODE = > "SCHEMA."
    REMOTE_LINK = > v_source_server_name,
    JOB_NAME = > v_project | ' _EXP_' | T_DATE,
    VERSION = > 'LAST');

    v_logfile: = DBMS_DATAPUMP. KU$ _FILE_TYPE_LOG_FILE;

    DBMS_DATAPUMP. ADD_FILE)
    MANAGE = > v_dp_job_handle,
    FILENAME = > v_project | ' _EXP_' | T_DATE |'. JOURNAL '.
    DIRECTORY = > 'DATAPUMP. "
    FILETYPE = > v_logfile);

    DBMS_DATAPUMP. () METADATA_FILTER
    MANAGE = > v_dp_job_handle,
    NAME = > 'SCHEMA_EXPR ',.
    VALUE = > ' = "' | v_project | " ' ') ;

    DBMS_DATAPUMP. START_JOB (v_dp_job_handle);

    v_percent_done: = 0;
    v_job_state: = "UNDEFINED";

    WHILE (v_job_state! = "COMPLETED") AND (v_job_state! = "STOPPED")
    LOOP
    DBMS_DATAPUMP. GET_STATUS)
    v_dp_job_handle,
    DBMS_DATAPUMP. KU$ _STATUS_JOB_ERROR + DBMS_DATAPUMP. KU$ _STATUS_JOB_STATUS + DBMS_DATAPUMP. KU$ _STATUS_WIP.
    -1,
    v_job_state,
    v_status);

    v_job_status: = v_status. JOB_STATUS;

    IF v_job_status. PERCENT_DONE! = v_percent_done THEN
    DBMS_OUTPUT. Put_line ('* percent of the job done = ' |) To_char (v_job_status. PERCENT_DONE));
    v_percent_done: = v_job_status. PERCENT_DONE;
    END IF;

    IF BITAND (v_status. MASK, DBMS_DATAPUMP. KU$ _STATUS_WIP)! = 0 THEN
    v_message: = v_status. WORK IN PROGRESS;
    ELSIF BITAND (v_status.mask, DBMS_DATAPUMP. KU$ _STATUS_JOB_ERROR)! = 0 THEN
    v_message: = v_status. ERROR;
    ON THE OTHER
    v_message: = NULL;
    END IF;

    IF v_message IS NOT NULL THEN
    v_count: = v_message. FIRST;
    While v_count IS NOT NULL
    LOOP
    DBMS_OUTPUT. Put_line (v_message (v_count). LOGTEXT);
    v_count: = v_message. Next (v_count);
    END LOOP;
    END IF;
    END LOOP;

    DBMS_OUTPUT. Put_line ("' job has completed");
    DBMS_OUTPUT. Put_line (' State of the Final work = ' | v_job_state);

    DBMS_DATAPUMP. Detach (v_dp_job_handle);
    END;

    TO_LOB can be used to insert, create table in select and update the instructions to convert

    So: You simply cannot use it in SELECT..., you can use CREATE TABLE BLAH AS SELECT TO_LOB (LONG_COLUMN) OF DREADED_TABLE_WITH_LONG_COL;

  • DLL for LabWindows/CVI 8.0 with the bool data type

    Hello

    I want to use a new SWIR camera in LabWindows/CVI 8.0 (Windows XP 32bits).

    The company delivered with the camera produced a 32-bit dll by using Microsoft Visual C++ 2010. The .dll and .lib and .h files include a working SDK/API (some functions with the bool data type)

    Compilation-online syntax error, variable Boolean is not a data type in LabWindows/CVI 8.0

    Generate the import of DLL-online syntax error library

    I tried to convert bool char (typedef unsigned char bool => no more syntax error but the functions does not work.)

    What can I do?

    Martin

    Hello again, Naumann!

    Microsoft Visual C++ 2010 represents Boolean using 1 byte, as stated by MSDN: https://msdn.microsoft.com/en-us/library/tf4dy80a(v=vs.100).aspx

    I guess that you import C++ functions using the syntax for extern "C". Otherwise, because of the C++ name mangling wouldn't you able to bind C++ library against your code CVI.

    You can also specify how you import C++ functions?

    In addition, because you have not described the problem as a corruption of heads or runtime error, I guess the C++ library function is called correctly the CVI. That said, I tend to believe that the problem is not really in the mechanism of interaction of C/C++, but in the C++ library. If you would start calling a dummy C++ function returning an integer from a simple CVI application that should work, because redefine bool in CVI 1 byte must ensure that settings are correctly transferred onto the stack.

    If you need to create a wrapper function of C++ that is not using bool and calls the C++ function, I expect to return the same result.

    Maybe you are missing a few prior initialization steps required? The provider of the camera also comes all example code?

    Best regards!

    -Johannes

  • Problem with the CLOB data type.

    Greetings,

    I am facing a problem with the CLOB data type. I know that the CLOB data type is 4 GB (I use Oracle 9i). But in the Pl Sql procedure, I can only store 34305 size for a CLOB variable character data.

    This is the test script that I am trying to run.

    DECLARE
    -Local variables here*.
    I have INTEGER;
    C_1 CLOB.
    BEGIN
    FOR Rec IN (SELECT
    *
    ACCORDING TO THE TABLE)
    LOOP
    C_1: = c_1 | Rec.Clo_1;
    END LOOP;
    EXCEPTION
    WHILE OTHERS THEN
    Dbms_Output.put_line (SQLERRM);
    END;


    Here variable C_1 range value 34305 good character regardless of type CLOB. Now the above script fails if query my buckle - huge number of return values. It is throwing the exception "error during transfer of files ORA-06502: PL/SQL: digital error or value."

    He would be grateful if someone can help me on this.

    Thank you.

    You are probably better off using DBMS_LOB.append, instead of the concatenation of varchar2 (|).

    And... take off your when-other Manager exceptions, please...

  • is the new compatible update 37.0.1 with the norton toolbar? If not when?

    is the new compatible update 37.0.1 with the norton toolbar? If not when?

    According to Norton, he works with 37, https://community.norton.com/en/blogs/product-update-announcements/firefox-37-support-norton-toolbar

  • Download all packages or just the sound with the latest dates?

    Hi, maybe it's a stupid question, but when you go to the drivers and it shows are all pilots who are selected to download to your laptop you wanted to install only those with the latest dates or each package that is there?

    Hello:

    You must install the driver with the most recent date if you are sure this is a driver that you are interested in.

  • How to create two different smart albums with photos with the same date?

    I created a smart album by using 'Date is' and ' keyword is EAA.»  (The photos have a keyword like "EAA" or "Flower".  Photos of keyword EAA & flower have the same date.)  When I use "Corresponding to all" are has no pictures in the album.  When I use "Match any" all the photos are in the album - EAA & flower.  I would like an album with only pictures of CEA for that date and another album with photos of flower with the same date.

    I get the same answer.  I can get the date and to a key word to work with 'all' selected, but not date and keywords.  So you will need two smart albums: one with date and ECA ('all' selected) and the other with date and flowers ('all' selected).

    Use the file menu option ➙ new Smart Album.

    Report the problem to Apple via https://www.apple.com/feedback/photos.html.

  • problem with the backup data in text file

    Hello

    The problem I am facing wihile, saving the data in the text file is that everytime when I'm slecting the path of the façade, data that are recorded are added with the previous data, not only in the new text, the new data set is saved but also, is there any previuos run for the program , the corresponding data is also present in this text file.

    However, when I change the same ''(file path) to 'constant' in the control block diagram, and then add the path of the file, it doesn't have this problem. Basically, changing the "file path" constant in the diagram of control block (so that it is displayed in the front panel) is at the origin of the problem.

    Help, please!

    Thank you

    Your shift on the loop Register For is not initialized. It will keep the value of the string since the last time that he performed. That initialize and it should solve your problem.

  • my updates are not proceed with the installation even if it is powered. I've had a wndows XP SP2

    my updates are not proceed with the installation even if it is powered. I've had a wndows XP SP2

    my updates are not proceed with the installation even if it is powered. I've had a wndows XP SP2

    If you mean that Windows updates are not proceed with the installation, it is because the support of Windows XP Service Pack 2 ended on July 13, 2010, so no updates were available for this purpose since then.

    http://Windows.Microsoft.com/en-us/Windows/help/end-support

    To resolve this problem, you MUST upgrade to Windows XP Service Pack 3, which is covered and a link procided further to the bottom of the page at the link above.

    Rob

  • Windows update keeps reminding me with the same updates

    Windows update keeps reminding me with the same updates

    See the article after some troubleshooting for your question:

    http://support.Microsoft.com/kb/910339/en-us >

    Please let us know if it did or did not help to solve your problem.

    UTC/GMT is 22:22 Monday, may 28, 2012

  • Failure of the installation of the Windows SDK on Windows 7 x 64. "the installation failed with the return code 5100.

    I try and install the SK and it fails for Web and ISO Setup > DVD drive. Same error every time:

    12:22:50 Wednesday, July 11, 2012: C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup\SFX\vcredist_x64.exe install failed with return code 5100

    The following lines are less useful because they suggest to go to a place that I did not.

    12:23:21 Wednesday, July 11, 2012: [SDKSetup:Error] Config_Products_Install: product Installation Microsoft Windows SDK for Windows 7 (failure): Please refer to Samples\Setup\HTML\ConfigDetails.htm document for more information. Fireplace: In SDKSetup.Product.ConfigureRelatedSfx () at SDKSetup.Product.ConfigureNewProduct (ManualResetEvent CancelEvent)
    12:23:21 Wednesday, July 11, 2012: [SDKSetup] Config_Products_InstallNew: complete the installation of the new product: Microsoft Windows SDK for Windows 7
    12:23:21 Wednesday, July 11, 2012: [SDKSetup:Error] Config_Products_Install: software Windows (failed) SDK installation: Installation of the product 'Microsoft Windows SDK for Windows 7' reported the following error: Please refer to Samples\Setup\HTML\ConfigDetails.htm document for more information. Fireplace: SDKSetup.Product.ConfigureNewProduct (ManualResetEvent CancelEvent) at SDKSetup.Product.SetupProduct (TaskMode taskMode, ManualResetEvent CancelEvent) at SDKSetup.ProductCollection.SetupProducts (TaskMode taskMode, believing believing, ManualResetEvent cancelEvent) to the SDKSetup.ConfigProducts.DoCurrentTask (Group TaskMode)

    Any ideas what could be worng? The rest of the log file is too big for this message but I can send it to someone who can help.

    Hello

    I suggest you try the steps listed from the link below,

    Windows SDK fails to install with the return Code 5100

    http://support.Microsoft.com/kb/2717426/de

  • As an operator with the long data type

    Oracle 10g.

    Hi gurus

    I want to apply as an operator on the long data type, but I get the error message, can you please help me why is that I use as an operator with the long data type. I did some research and but unable to find a solution, see query for more details below...

    Query

    SELECT trigger_body FROM user_triggers

    WHERE trigger_body LIKE '% UPDA % CASE % ';

    Error

    ORA-00932: inconsistent data types: expected NUMBER got LONG

    00932 00000 - ' incompatible data types: wait %s %s got. "

    * Cause:

    * Action:

    Error on line: column 2: 7

    Concerning

    Muzz

    Adrian Billington wrote to the top of your options.

    working with long columns

Maybe you are looking for

  • Install Firefox sync does not not on fresh Ubuntu

    Fresh installation of Ubuntu 64-bit 13.10 with a new installation of Firefox 25. The installation of Firefox Sync program worked flawlessly, except that it does not work. I not encounter errors, and when I said to synchronize the process seems to com

  • Equium A110-240 need new replacement keyboard

    Hey.As the title says I have a portable satellite A110-240 with a broken keyboard. A few weeks about 1/3 of the keys stopped working at the same time. The error is probably in the material and I reinstalled the keyboard and put drivers just in case B

  • BIOS update question

    Hi, I recently got a ThinkCentre M52 8113-E7U TC series My question is about the BIOS update. If I update to the latest version, this is includes all fixes from previous versions? I noticed, that I can not boot from USB more than flash drives 2 GB, I

  • I need hotfix # 921 337

    I need hotfix # 921 337

  • Are the US 3 G Xoom network locked?

    Hi all I live in Australia and I am wanting to buy a Motorola Xoom. I have a Samsung Galaxy Tab for the moment but would really like the larger screen. The Xoom is not for sale yet in Australia. I'm looking to buy a Xoom slightly used on ebay, if I c