Problems updating multiple columns with a TO... SELECT subquery

Hello

This statement works very well:

UPDATE scott.dept
SET (deptno) = (WITH AS gaga
(SELECT 1
THE DOUBLE)
SELECT DeptNo
GAGA)
/

The second statement gives an error ORA-01767: UPDATE... GAME expression must be a subquery:

UPDATE scott.dept
SET (deptno, dname) = (WITH AS gaga
(SELECT 1,
'CHANGED '.
THE DOUBLE)
SELECT deptno,
DNAME
GAGA)
/

What's wrong? Is this a limitation of Oracle 9i?

Thank you
Heinz

Hello

It is not fair to Oracle 9; I get the same error in Oracle 11.
Use MERGE instead of UPDATE. (Sorry, I do not have Oracle 9, so I can't test that it works there, but WITH works MERGE in Oracle 10 and 11; no hide or workaround is necessary).

If you want to use the UPDATE and you really need to use a WITH clause (and, of course, you don't have in this simple example), you can hide the WITH clause in a view in line, like this:

UPDATE scott.dept
SET ( deptno, dname ) = (
                                   SELECT  *
                 FROM        (
                           WITH gaga AS
                         (        SELECT  1, ...
                         ) ...
                      )
                  )
;

Tags: Database

Similar Questions

  • Problem updating multiple rows in the table using subquery

    Hi everyone, I can't update multiple lines with a subquery. Here is the configuration:
    create table mytable (
    col_a number primary key,
    col_b number,
    col_c number,
    col_d number);
    
    insert into mytable values (1 ,1,1,15);
    insert into mytable values (2 ,1,2,7 );
    insert into mytable values (3 ,1,3,11);
    insert into mytable values (4 ,1,4,23);
    insert into mytable values (5 ,1,5,14);
    insert into mytable values (6 ,2,1,50);
    insert into mytable values (7 ,2,2,41);
    insert into mytable values (8 ,2,3,13);
    insert into mytable values (9 ,2,4,12);
    insert into mytable values (10,2,5,19);
    insert into mytable values (11,3,1,10);
    insert into mytable values (12,3,2,92);
    insert into mytable values (13,3,3,81);
    insert into mytable values (14,3,4,17);
    insert into mytable values (15,3,5,66);
    insert into mytable values (16,4,1,54);
    insert into mytable values (17,4,2,41);
    insert into mytable values (18,4,3,22);
    insert into mytable values (19,4,4,24);
    insert into mytable values (20,4,5,17);
    For this example, by using an update statement (or merge if this is better), I mean set values for col_d where col_b = 3 equal to that of the col_d where col_b = 1 and col_c equal between them. Results should resemble the following after the update:
    col_a col_b col_c col_d
    1     1     1     15
    2     1     2     7
    3     1     3     11
    4     1     4     23
    5     1     5     14
    6     2     1     50
    7     2     2     41
    8     2     3     13
    9     2     4     12
    10    2     5     19
    11    3     1     15
    12    3     2     7
    13    3     3     11
    14    3     4     23
    15    3     5     14
    16    4     1     54
    17    4     2     41
    18    4     3     22
    19    4     4     24
    20    4     5     17
    I see her there within my reach using this query, where I want to put b_col_d = a_col_d, but miss me something, this query returns too many rows when it is used in the update statement.
    select * from (
      select col_a as a_col_a, col_b as a_col_b, col_c as a_col_c, col_d as a_col_d
      from mytable
      where col_b = 1
      ) a, (
      select col_a as b_col_a, col_b as b_col_b, col_c as b_col_c, col_d as b_col_d
      from mytable
      where col_b = 3
      ) b
    where a.a_col_c = b.b_col_c
    Update column_d set mytable = (select? where?)

    Can someone help me get there? I use 10 gr 2.

    Thank you!
    Mark

    I hope that's what you're looking for:

    SQL > UPDATE mytable myt1
      2  SET    col_d = ( SELECT myt2.col_d
      3                   FROM   mytable myt2
      4                   WHERE  myt2.col_b = 1
      5                   AND    myt1.col_c = myt2.col_c
      6                 )
      7  WHERE  col_b = 3
      8  AND    EXISTS
      9         ( SELECT NULL
     10           FROM   mytable myt2
     11           WHERE  myt2.col_c = myt1.col_c
     12         )
     13  ;
    
    5 rows updated.
    
    SQL > SELECT * FROM mytable ORDER BY col_a;
    
                   COL_A                COL_B                COL_C                COL_D
    -------------------- -------------------- -------------------- --------------------
                       1                    1                    1                   15
                       2                    1                    2                    7
                       3                    1                    3                   11
                       4                    1                    4                   23
                       5                    1                    5                   14
                       6                    2                    1                   50
                       7                    2                    2                   41
                       8                    2                    3                   13
                       9                    2                    4                   12
                      10                    2                    5                   19
                      11                    3                    1                   15
                      12                    3                    2                    7
                      13                    3                    3                   11
                      14                    3                    4                   23
                      15                    3                    5                   14
                      16                    4                    1                   54
                      17                    4                    2                   41
                      18                    4                    3                   22
                      19                    4                    4                   24
                      20                    4                    5                   17
    
    20 rows selected.
    

    Thank you very much for providing the sample data in a format that is easy to consume form, as well as the expected results.

  • UPDATE multiple columns with conditional parameters

    I have a procedure that updates several columns of a table using the parameter of the procedure. Is it possible to have a update unique with the parameter SET conditional statement?
    CREATE TABLE TEMP
    (POL_NUM NUMBER,
    OED DATE,
    TERM NUMBER,
    TRANS_CD CHAR(2));
    
    INSERT INTO TEMP VALUES (1, '1 AUG 2009', 12, 'NB');
    INSERT INTO TEMP VALUES (2, '4 AUG 2009', 12, 'XL');
    INSERT INTO TEMP VALUES (3, '2 AUG 2009', 12, 'RN');
    COMMIT;
    
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM NUMBER,
      pOED IN DATE,
      pTERM IN NUMBER,
      pTRANS_CD CHAR2)
    AS
    BEGIN
      IF pOED IS NOT NULL THEN
        UPDATE TEMP SET OED = pOED WHERE POL_NUM = pPOL_NUM;
      END IF;
    
      IF pTERM IS NOT NULL THEN
        UPDATE TEMP SET TERM = pTERM WHERE POL_NUM = pPOL_NUM;
      END IF;
    
      IF pTRAN_CD IS NOT NULL THEN
        UPDATE TEMP SET TRANS_CD = pTRANS_CD WHERE POL_NUM = pPOL_NUM;
      END IF;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
         NULL;
    END;
    Is it possible to replace several IFs code to have only one UPDATE statement with the condition that update the column only if the parameter passed is not null? In the real world scenario, I have more than 3 columns and I do not want to write lots of IF blocks.

    Please help gurus!

    Published by: Kuul13 on September 18, 2009 13:26

    Hello

    Maybe this,.

    Create OR Replace Procedure TMP_PROC( pPOL_NUM  IN Number
                                        , pOED      IN Date
                                        , pTERM     IN Number
                                        , pTRANS_CD IN Varchar2 ) As
    Begin
       UPDATE TEMP
          SET OED      = NVL(POED     , OED )
            , TERM     = NVL(PTERM    , TERM )
            , TRANS_CD = NVL(PTRANS_CD, TRANS_CD )
        WHERE POL_NUM = PPOL_NUM;
       Commit;
    Exception
       When Others Then
          Null;
    End;
    

    Kind regards
    Christian Balz

  • Update multiple columns with case

    I have this and I wanted to have it in a single update to the case when then etc. Anyone?

    UPDATE TABLE_NAME

    SET CIITM_ITEM_RATE = 9

    WHERE CIITM_APPLICATION = 7 AND CIITM_ITEM_RATE = 11 AND CIITM_CODE = 2;

    --8288 lines are updated.

    UPDATE TABLE_NAME

    SET CIITM_ITEM_RATE = 9, CIITM_NUMIT = 2

    WHERE CIITM_APPLICATION = 7 AND CIITM_ITEM_RATE = 12 AND CIITM_CODE = 2;

    -513 lines to date.

    UPDATE TABLE_NAME

    SET CIITM_ITEM_RATE = 9, CIITM_NUMIT = 3

    WHERE CIITM_APPLICATION = 7 AND CIITM_ITEM_RATE = 13 AND CIITM_CODE = 2;

    -39 lines to date.

    UPDATE TABLE_NAME

    SET CIITM_ITEM_RATE = 9, CIITM_NUMIT = 4

    WHERE CIITM_APPLICATION = 7 AND CIITM_ITEM_RATE = 14 AND CIITM_CODE = 2;

    -15 updated lines to date.

    UPDATE TABLE_NAME

    SET CIITM_ITEM_RATE = 9, CIITM_NUMIT = 5

    WHERE CIITM_APPLICATION = 7 AND CIITM_ITEM_RATE = 15 AND CIITM_CODE = 2;

    -5 lines to date.

    UPDATE TABLE_NAME

    SET CIITM_ITEM_RATE = 9, CIITM_NUMIT = 6

    WHERE CIITM_APPLICATION = 7 AND CIITM_ITEM_RATE = 16 AND CIITM_CODE = 2;

    -4 lines to date.

    UPDATE TABLE_NAME

    SET CIITM_ITEM_RATE = 9, CIITM_NUMIT = 7

    WHERE CIITM_APPLICATION = 7 AND CIITM_ITEM_RATE = 17 AND CIITM_CODE = 2;

    UPDATE TABLE_NAME

    SET CIITM_ITEM_RATE = 9,

    CIITM_NUMIT = CASE CIITM_ITEM_RATE

    11. WHEN CAN CIITM_NUMIT

    OF OTHER CIITM_ITEM_RATE - 10

    END

    WHERE CIITM_APPLICATION = 7

    AND CIITM_ITEM_RATE BETWEEN 11 AND 17

    AND CIITM_CODE = 2;

    SY.

  • Update multiple columns from multiple tables in a single UPDATE request

    Hello

    I'm trying to figure if I'm heading in the right direction.

    I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.

    Scenario 1

    UPDATE Table2, Table 3
    SET T2.Column1 = T1.Column1 
    ,T2.Column2 = T1.Column2
    ,T3.Column2 = T1.Column2
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T1.id = T2.id
    and T1.id = T3.id
    
    

    Scenario 2

    UPDATE Table3
    SET T3.Column1 = T1.Column1 
    T3.Column2 = T1.Column2
    ,T3.Column3 = T2.Column3
    ,T3.Column4 = T2.Column4
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T3.id = T1.id
    and T3.id = T2.id
    
    

    Hello

    For scenario 1, you must write separate instructions UPDATE table2 and table3.

    To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.

    ENGAGE only when two tables have been changed.

    You can write a procedure or an INSTEAD OF trigger to do all this.

    For scenario 2, you can reference many tables that you need when new table3.  It might be more efficient and simpler to use the MERGER rather than UPDATED.  For example:

    MERGE INTO table3 dst

    WITH THE HELP OF)

    SELECT t1.id

    t1.column1

    t1.column2

    t2.column3

    t2.column4

    FROM table1 t1

    JOIN table2 t2 ON t1.id = t2.id

    )             src

    WE (dst.id = src_id

    WHEN MATCHED THEN UPDATE

    SET dst.column1 = src.column1

    dst.column2 = src.column2,

    dst.column3 = src.column3,

    dst.column4 = src.column4,

    ;

  • Update multiple records with PHP

    Hey,.

    I want to update multiple lines with a single click on the submit button.

    Unfortunately, it does not work. What's not in the code?

    <? php require_once('.. / Connections/ikon.php');? >
    <? PHP
    If (! function_exists ("GetSQLValueString")) {}
    function GetSQLValueString ($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    If (via PHP_VERSION < 6) {}
    $theValue = get_magic_quotes_gpc()? stripslashes ($TheValue): $theValue;
    }

    $theValue = function_exists ("mysql_real_escape_string")? mysql_real_escape_string ($TheValue): mysql_escape_string ($theValue);

    Switch ($theType) {}
    case 'text ':
    $theValue = ($theValue! = "")? « " ». $theValue. "" "": "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue! = "")? intval ($TheValue): 'NULL ';
    break;
    case "double":
    $theValue = ($theValue! = "")? doubleVal ($TheValue): 'NULL ';
    break;
    case "date":
    $theValue = ($theValue! = "")? « " ». $theValue. "" "": "NULL";
    break;
    case "set":
    $theValue = ($theValue! = "")? $theDefinedValue: $theNotDefinedValue;
    break;
    }
    Return $theValue;
    }
    }

    $editFormAction = $_SERVER ['PHP_SELF'];
    If (isset {}

    $editFormAction. = « ? ». htmlentities($_SERVER['QUERY_STRING']);
    }

    for ($j = 0, $len = count($_POST['id']); $j < $len; $j ++) {}
    If ((isset($_POST["MM_update"])) & & ($_POST ["MM_update"] == "openingsuren_wijzigen")) {}
    $updateSQL = sprintf ("UPDATE ikon_openingsuren SET dag = %s voormiddag = %s, namiddag = WHERE id = %s %s",
    GetSQLValueString ($_POST ['dag'] [$j], "text").
    GetSQLValueString ($_POST ['voormiddag'] [$j], "text").
    GetSQLValueString ($_POST ['namiddag'] [$j], "text").
    GetSQLValueString ($_POST ['id'] [$j], "int"));

    @mysql_select_db ($database_ikon, $ikon);
    $Result1 = mysql_query ($updateSQL, $ikon) or die (mysql_error ());
    }
    }

    @mysql_select_db ($database_ikon, $ikon);
    $query_rsWijzigOpeningsuren = "SELECT * from ikon_openingsuren";
    $rsWijzigOpeningsuren = mysql_query ($query_rsWijzigOpeningsuren, $ikon) or die (mysql_error ());
    $row_rsWijzigOpeningsuren = mysql_fetch_assoc ($rsWijzigOpeningsuren);
    $totalRows_rsWijzigOpeningsuren = mysql_num_rows ($rsWijzigOpeningsuren);
    ? >


    <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict / / IN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > ""
    "< html xmlns ="http://www.w3.org/1999/xhtml">".
    < head >
    < meta http-equiv = "content-type" content = text/html"; charset = utf-8 "/ >"
    < title > < / title >
    < / head >
    < body >
    < form action = "<?" PHP echo $editFormAction;? ">" method = "POST" name = "openingsuren_wijzigen" id = "openingsuren_wijzigen" >
    < input name = "id []" type = "hidden" id = "id" value = "<?" PHP echo $row_rsWijzigOpeningsuren ['id'];? ">" / >
    < table id = "tbl_openingsuren" >
    < thead >
    < b >
    < scope = "col" th > Dag < /th >
    < scope = "col" th > Voormiddag < /th >
    < scope = "col" th > Namiddag en Avond < /th >
    < /tr >
    < / thead >
    < tbody >
    <? PHP {? >}
    < b >

    < td > < input name = "dag []" type = "text" id = "dag" value = "<?" PHP echo $row_rsWijzigOpeningsuren ['dag'];? ">" size = "15" maxlength = "15" / > < table >
    < td > < input name = "[to] voormiddag" type = "text" id = "voormiddag" value = "<?" PHP echo $row_rsWijzigOpeningsuren ["voormiddag"];? ">" size = "15" maxlength = "15" / > < table >
    < td > < input name = "[of] namiddag" type = "text" id = "namiddag" value = "<?" PHP echo $row_rsWijzigOpeningsuren ["namiddag'];? ">" size = "15" maxlength = "15" / > < table >
    < /tr >
    <? PHP} while ($row_rsWijzigOpeningsuren = mysql_fetch_assoc ($rsWijzigOpeningsuren));? >
    < / tbody >
    < /table >
    < p > < input type = "submit" name = "submit" id = "submit" value = "Stayed" class = "knop" / > < / p >
    < input type = "hidden" name = "MM_update" value = "openingsuren_wijzigen" / >
    < / make >
    < / body >
    < / html >
    <? PHP
    mysql_free_result ($rsWijzigOpeningsuren);
    ? >

    Powerlait wrote:

    I want to update multiple lines with a single click on the submit button.

    Unfortunately, it does not work. What's not in the code?

    It would be more useful if you were to say what is happening. "It doesn't work" is not very useful.

    However, a quick look at your code is your hidden field that contains the ID outside the loop (repeat region) in your form. Place it inside the loop like this:

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

  • Select cursor for update: multiple columns of different tables

    Hello

    I have two tables test1 and test2. I want to udpate the column (DEPT_DSCR) from the TEST1 and TEST2 using select for update and current tables of the... with the cursor.

    I have a code drafted as follows:
    DECLARE
    v_mydept1 TEST1. TYPE % DEPT_CD;
    v_mydept2 TEST2. TYPE % DEPT_CD;
    CURSOR C1 IS SELECT TEST1. DEPT_CD, TEST2. DEPT_CD OF TEST1, TEST2 WHERE TEST1. DEPT_CD = TEST2. DEPT_CD AND TEST1. DEPT_CD IS 'AA' FOR THE UPDATE OF TEST1. DEPT_DSCR, TEST2. DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1, v_mydept2;
    WHEN EXIT C1% NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR IS "PLSQL1" WHERE CURRENT OF C1;.
    SETTING A DAY TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1.
    END LOOP;
    COMMIT;
    END;

    The code above when it is run, declares that it runs successfully. But it does not update the columns you want [DEPT_DSCR].

    It works only when we want to update one or more columns of the same table... i. e by providing these columns after ' to UPDATE THE.
    I don't know what exactly is the problem when you want to update several columns of different tables.

    Can someone help me on this?

    user12944938 wrote:
    But it's more the notion of compensation and understanding.

    See the link below:
    http://download.Oracle.com/docs/CD/B10501_01/AppDev.920/a97269/pc_06sql.htm

    See the section RESTRICTION in the link above.

    Twinkle

  • Update a column with randomly selected values

    Hello

    We have a chart of accounts that represents mainly the brands & channels. an example is shown below.

    account_ID chain_id brand_id service

    1 11 NULL NULL

    1 12 NULL NULL

    2 11 NULL NULL

    Here, I want to update the chain_id & brand_id which are currently ZERO in order to make all the eligible ranks for further processing. There is another table (say chain_brand) that maintains the relationship between chain_id and brand_id. a chain_id can have several brand_ids

    for example, chain_id brand_id

    101 2011

    101 2012

    102 2020

    Now I need a script that could randomly choose the values in the chain_brand table, and update the table accountable. condition is that these values must be unique for an argument account_id

    EG.,.

    account_ID chain_id brand_id service

    1 101 2011 11

    1 101 2011 12

    2 102 2020 11

    so each account can be attached to a single chain_id and a brand_id.

    Please suggest how this can be achieved.

    TIA.

    There is probably a pure sql solution far superior to mine... but in pl/sql

    Start

    for c in (select account_id, separate accounts)

    loop

    Update accounts

    package (chain_id, brand_id) = (select chain_id, brand_id

    from (select *)

    of chain_brands

    order of dbms_random.value)

    where rownum = 1)

    where account_id = c.account_id;

    end loop;

    end;

  • Update updated the columns with null are excluded from the DB adapter

    Hi all

    My fusion system interacts with DB2 using the DB adapter.

    I have a script that I need to update a flag in the table after completing my bpel workflow. But by updating the value of indicator to "Processsed", there are other columns with a NULL value.

    How to solve this problem. I don't want to do, the other columns should not be alerted.

    Thank you

    Richa

    Hello

    The issue has been resolved. In fact, I've updated the update statement, excluding items that couldnot be updated top link mappings. I had to create a new adapter and it worked.

    Concerning

  • update of column with the number of sequence based on the condition


    Hello

    Version of DB: database Oracle 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    Here's the script to reporduce:

    CREATE TABLE T2
    (
    PARAMLOCATION NVARCHAR2 (16).
    PARAMTYPE VARCHAR2 (3 BYTE),
    PARAMNUM VARCHAR2 (3 BYTE)
    )

    Insert into T2
    (PARAMLOCATION)
    Values
    ('49');
    Insert into T2
    (PARAMLOCATION)
    Values
    (« 12 ») ;
    Insert into T2
    (PARAMLOCATION)
    Values
    (« 50 ») ;
    Insert into T2
    (PARAMLOCATION, PARAMTYPE)
    Values
    ('loc51', 'B');
    Insert into T2
    (PARAMLOCATION, PARAMTYPE)
    Values
    ('loc52', 'B');
    Insert into T2
    (PARAMLOCATION, PARAMTYPE)
    Values
    ('loc53', 'B');
    Insert into T2
    (PARAMLOCATION)
    Values
    ("loc54");
    Insert into T2
    (PARAMLOCATION)
    Values
    ("loc55");
    Insert into T2
    (PARAMLOCATION, PARAMTYPE)
    Values
    ('aoc01', 'I');
    Insert into T2
    (PARAMLOCATION, PARAMTYPE)
    Values
    ('aoc02', 'I');
    Insert into T2
    (PARAMLOCATION)
    Values
    ("loc58");
    Insert into T2
    (PARAMLOCATION, PARAMTYPE)
    Values
    ("doc03", "DL");
    Insert into T2
    (PARAMLOCATION, PARAMTYPE)
    Values
    ("doc02", "DL");
    Insert into T2
    (PARAMLOCATION, PARAMTYPE)
    Values
    ("doc01", "DL");

    I should update the column in table (paramnum) function sequential paramtype as this: also you can not order in paramlocation, its like that paramlocation comes first start sequence ordering from there based on paramtype.

    PARAMLOCATIONPARAMTYPEPARAMNUM
    49
    12
    50
    loc51B1
    loc52B2
    loc53B3
    loc54
    loc55
    aoc01AI1
    aoc02AI2
    loc58
    doc03DL1
    doc02DL2
    doc01DL3

    Please advice.

    Hello

    I'll assume you have a column called load_order, which corresponds to the order of the lines:

    CREATE TABLE T2
    (
    NUMBER OF LOAD_ORDER
    PARAMLOCATION NVARCHAR2 (16).
    PARAMTYPE VARCHAR2 (3 BYTE),
    PARAMNUM VARCHAR2 (3 BYTE)
    ) ;

    Insert into T2
    (LOAD_ORDER, PARAMLOCATION)
    Values
    (1, '49');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION)
    Values
    (2, '12');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION)
    Values
    (3, '50');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
    Values
    (5, 'loc51', 'B');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
    Values
    (8, 'loc52', 'B');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
    Values
    (13, 'loc53', 'B');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION)
    Values
    (13.2, "loc54");
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION)
    Values
    (13.5, 'loc55');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
    Values
    (50, 'aoc01', 'I');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
    Values
    (80, 'aoc02', 'I');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION)
    Values
    (81, 'loc58');
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
    Values
    (82, "doc03", "DL");
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
    Values
    (83, "doc02", "DL");
    Insert into T2
    (LOAD_ORDER, PARAMLOCATION, PARAMTYPE)
    Values
    (99, "doc01", "DL");

    Any data type, this column is or what are the values it contains, as long as you can derive from the order of the rows of values in the column.  (Of course, the values can be consecutive integers, only they do not have to be).  If you do not have this type of column, you don't have any order to your lines, and what you request is impossible.

    Since you have a load_order column, here's a way to get the results you requested:

    MERGE INTO dst t2

    WITH THE HELP OF)

    WITH got_grp AS

    (

    SELECT load_order

    paramlocation

    paramtype

    ROW_NUMBER () OVER (ORDER BY load_order)

    -ROW_NUMBER () OVER (PARTITION BY CASE

    WHEN paramtype IS NULL

    THEN 0

    END

    ORDER BY load_order

    ) AS the grp

    THE t2

    )

    SELECT load_order

    paramlocation

    ROW_NUMBER () OVER (PARTITION BY grp

    ORDER BY load_order

    ), Paramnum

    OF got_grp

    WHERE the paramtype IS NOT NULL

    ) CBC

    WE (dst.paramlocation = src.paramlocation)

    WHEN MATCHED THEN UPDATE

    SET dst.paramnum = src.paramnum

    ;

    Results:

    LOAD_ORDER PARAMLOCATION BY

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

    1 49

    2 12

    3 50

    loc51 5 B 1

    loc52 8 B 2

    13 loc53 B 3

    13.2 loc54

    loc55 13.5

    50 aoc01 AI 1

    80 aoc02 AI 2

    loc58 81

    1 DL of 82 doc03

    2 DL doc02 83

    3 DL of 99 doc01

  • Update of column with the rank on the parition

    Hi, I have a table A given as:
    MASTER_ID, CHILD_ID
    100...
    100...
    100...
    101...
    101...
    102...
    102...
    102...
    102...

    The initial values of CHILD_ID are garbage and should be updated as follows:
    For each unique MASTER_ID the CHILD_ID should have values beginning with 1 (with lowest rowid)
    so when this column is updated the table should look like:
    MASTER_ID, CHILD_ID
    100, 1
    100, 2
    100, 3
    101, 1
    101, 2
    102, 1
    102, 2
    102, 3
    102, 4

    Select MASTER_ID, CHILD_ID,
    Rank() over (partition by MASTER_ID order by rowid) as rank
    a.

    give the good ranking, but when I try to update the CHILD_ID with this rank

    Update)
    Select MASTER_ID, CHILD_ID,
    Rank() over (partition by MASTER_ID order by rowid) as rank
    of (A)
    Set CHILD_ID = row_id

    I get the error:
    SQL error: ORA-01732: non-legal data manipulation operation on this point of view
    01732 00000 - 'operation not legal data manipulation on this point of view'

    Can you please help me with an sql update to set this child_id?
    Thank you
    create table masta
    (
       pk_id number,
       ch_id number
    );
    
    insert into masta values (1, 0);
    insert into masta values (1, 0);
    insert into masta values (1, 0);
    
    insert into masta values (2, 0);
    
    ME_XE?merge into masta m
      2  using
      3  (
      4     select
      5        row_number() over(partition by pk_id order by 1) rn,
      6        rowid as the_rowid
      7     from masta
      8  ) m1
      9  on
     10  (
     11     m.rowid = m1.the_rowid
     12  )
     13  when matched then update set m.ch_id = m1.rn;
    
    4 rows merged.
    
    Elapsed: 00:00:00.14
    ME_XE?select * from masta;
    
                 PK_ID              CH_ID
    ------------------ ------------------
                     1                  1
                     1                  2
                     1                  3
                     2                  1
    
    4 rows selected.
    
    Elapsed: 00:00:00.21
    ME_XE?
    

    Ideally, you do not want to fix the application so that 'unwanted values' are not met initially in the table.

  • How to update a column with 7 inputText on earpiece popupClose box

    12.1.3 JDev

    On the popup close listening port column on the home page is not refreshing.

    In the home page, I have a column with inputText 7 and a link (all are within the same column).

    When you click on the link, I'll open a popup.

    Popup close listener I am affecting certain values the inputText 7.

    but Popup close column is not refreshing.

    I tried to link partialTrigger with the inputTxt boxes but did not work.

    Also tried to make the main provision of the Panel including the inputTextbox group are surrounded, but not refreshing.

    Thank you.

    No difference if you call bindCreateTable.resetStampState () before programmatic refresh?

    Dario

  • Is it possible to update a column that has been selected as a KEY?

    Hello.

    I'm trying to run an interface that takes a distinct value of the column source and fill in the dimension of the target (table). Dimension of the target (table) has an another colum (surrogate key) which is filled through a sequence in oracle. Source and target are in Oracle. LMK used (Oracle Oracle (DBLINK) 2).

    Problem is when the key column must be defined with update so when I run the update checking interface in the active mapping window and update 'YES' in the IKM (incremental update of Oracle). I have an error message that ODI performs a step for updating the current lines (although table is empty) and says the table.column name is not valid. I agree that it makes sense, but how to solve this problem.

    If I select the surrogate (column number sewurnce) as gived key key always error. So to be precise how to deal with such a situation. Is it possible that I have create another column that is populated by a separate number by ODI and I do that as a key.

    Any help will be much appreciated.



    Table_name1 T update
    Set)

    ) =
    (
    Select

    of PFTW. I have _Table_name $ S
    where T.column_name1 = S.column_name1
    )

    where (column_name1)
    en)
    Select columns_name1
    of PFTW. I table_name1 $
    where IND_UPDATE = 'U '.
    )
    I'm the separate lines by checking the checkbox separate lines in the target zone properties window.

    As I understand it, you have two columns in the target, an excerpt from the Source a different surrogate key (that is, the sequence). In this case you would never updated, so go Oracle incremental updates with Option No. update and insert Yes.

  • update multiple columns in table B of table based on the corresponding pass.

    Hello

    Will have two tables as below,
    create table billing_info 
    (MS number,
    RT_ID number,
    BILL_NO number)
    
    create table mu 
    (MS number,
    RT_ID number,
    BILL_NO number)
    
    insert into billing_info (MS,RT_ID,BILL_NO) values (1,99,635);
    insert into billing_info (MS,RT_ID,BILL_NO) values (2,99,635);
    insert into billing_info (MS,RT_ID,BILL_NO) values (3,999,1635);
    insert into billing_info (MS,RT_ID,BILL_NO) values (4,599,7635);
    
    insert into mu(MS) values (1);
    insert into mu(MS) values (2);
    insert into mu(MS) values (3);
    insert into mu(MS) values (4);
    Here the table mu got nullability for columns RT_ID, BILL_NO. I need to update this coulmns in the mu of table with the RT_ID, BILL_NO of billing_info of table corresponding to the value of MS.

    How to on this subject.

    I tried the follwing examples

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:43440209618042

    and

    http://decipherinfosys.WordPress.com/2007/01/31/update-data-in-one-table-with-data-from-another-table/

    but without hope...

    It throws errors like ora-01779...
    UPDATE mu
       SET rt_id = (
          SELECT rt_id
            FROM billing_info
           WHERE billing_info.ms = mu.ms )
     WHERE EXISTS (
          SELECT 1
            FROM billing_info
           WHERE billing_info.ms = mu.ms )
    

    updates all lines of MU with the RT_ID of the line in BILLING_INFO where there is a MS value assuming that such a line exists in BILLING_INFO. This assumes that MU is unique in both tables. If there are duplicates, you will need to explain how to know which line of BILLING_INFO corresponds to a particular line of MU.

    Of course, from the point of view of standardization, two tables with the same key and the same nonkey column should be extremely unusual.

    Justin

Maybe you are looking for

  • Where can I find firefox 3.5 for linux?

    I need to install firefox 3.5 for linux, to be able to use a plugin that only works on this version. However, I can't find a working link to download 3.5 for linux anywhere on the web.

  • Tecra A3 - 152 - not able to read CD - R (or CD - RW), burned by itself or another PC

    Hello My TECRA A3-152 offers the CARPET * a DVD-RAM UJ - 831S player (1.40 firmware version) with the Microsoft (dated the 1.07.2001) 5.1.2535.0 driverThe laptop is not able to read the CD - R or CD - RW engraved with any other PC (or alone). The CD

  • record the location of the screenshots

    Hi all a straight line. Lollipop on the compact z3 appears to save screenshots in the internal memory, while they went to the external card of kitkat. Can a control where the screenshots get saved to with our lolloipop versions? Thank you Gary

  • Create the new data model

    How can I create a new data model?

  • Image width problem

    Hi, I put rectangles, put them as full width and filled with my image.The problem is they disply on my screen, on larger screens, the bottom of the image is cut off.If I want the image so that they display in their entirety on the screens, they becom