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

Tags: Database

Similar Questions

  • 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, ...
                             ) ...
                          )
                      )
    ;
    
  • 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,

    ;

  • How to avoid duplicates on a column with condition

    Hi all

    I need some advice here. At work, we have an Oracle APEX application that allow the user to add new records with the decision of the increment automatic number based on the year and the group name.

    Said that if they add the first record, group name AA, for 2012, they get the decision number AA 1 2013 as their record casein displayed page of the report.

    The second record of AA in 2013 will be AA 2 2013.

    If we add about 20 records, it will be AA 20 2013.

    The first record for 2014 will be AA 1 2014.

    However, recently, we get a claim of the user on two files of the same name of group have the same number of the decision.

    When I looked in the history table and find that the time gap between 2 record is about 0.1 seconds.

    In addition, we have the correspondence table which allows the user admin update the sequence number start with the restraint that it must be greater than the maximum number of the current name of the current year.

    This boot sequence number and the name of the group is stored together in a table.

    And in some other case, the user can add a decision duplicate for related record number. (this is a new feature)

    The current logic of the procedure to add the new record on the application are

    _Get max record table with selected group name (decision_number) and the current year.

    _INSERT in the folder table the new record came with the decision to number + 1

    _ update sequence number of the number of the decision just added.

    So instead of utitlising the process of editing the built-in automatic table of the APEX, I write a procedure that combine all three processes.

    I have run some loop for continually perform this procedure, and it seems that it can generate autotically new decision unique number with time about 0.1 second difference.

    However, when I increase the number of entry to 200 and let two users run 100 each.

    If the time gap is about 0.01 second, double decision numbers are displayed.

    What can I do to prevent duplicate?

    I can't just apply a unique constraint here for three columns with condition because it can be duplicated in some special conditions. I don't know much about the use of lock and its impact.

    This is the content of my procedure

    create or replace

    PROCEDURE add_new_case)

    -ID just use the trigger

    p_case_title IN varchar2,

    p_year IN varchar2,

    p_group_name IN VARCHAR2,

    -decisionnumber here

    p_case_file_number IN VARCHAR2,

    -active

    p_user in VARCHAR2

    )

    AS

    NUMBER default_value;

    caseCount NUMBER;

    seqNumber NUMBER;

    previousDecisionNumber NUMBER;

    BEGIN

    -execution immediate q '[alter session set nls_date_format = "dd/mm/yyyy"]';

    SELECT count (*)

    IN caseCount

    OF CASE_RECORD

    WHERE GROUP_ABBR = p_group_name

    AND to_number (to_char (create_date, "yyyy")) = to_number (to_char (date_utils.get_current_date, "yyyy"));

    SELECT max (decision_number)

    IN previousDecisionNumber

    OF CASE_RECORD

    WHERE GROUP_ABBR = p_group_name

    AND to_number (to_char (create_date, "yyyy")) = to_number (to_char (date_utils.get_current_date, "yyyy"));

    IF p_group_name IS NULL

    THEN seqNumber: = 0;

    ON THE OTHER

    SELECT Seq_number INTO seqNumber FROM GROUP_LOOKUP WHERE ABBREVIATION = p_group_name;

    END IF;

    IF caseCount > 0 THEN

    default_value: largest = (seqNumber, previousdecisionnumber) + 1;

    ON THE OTHER

    default_value: = 1;

    END IF;

    INSERT INTO CASE_RECORD (case_title, decision_year, GROUP_ABBR, decision_number, case_file_number, active_yn, created_by, create_date)

    VALUES (p_case_title, p_year, p_group_name, default_value, p_case_file_number, 'Y', p_user, sysdate);

    -Need to update the sequence here also

    UPDATE GROUP_LOOKUP

    SET SEQ_NUMBER = default_value

    WHERE the ABBREVIATION = p_group_name;

    COMMIT;

    EXCEPTION

    WHILE OTHERS THEN

    Logger.Error (p_message_text = > SQLERRM)

    , p_message_code = > SQLCODE

    , p_stack_trace = > dbms_utility.format_error_backtrace

    );

    LIFT;

    END;

    Many thanks in advance,

    Ann

    It's easier to solve for the case, while p_group_name is not null. In this case, you update a GROUP_LOOKUP line, so that you can select to update this line at the beginning, to prevent cases of two for the same group added at the same time. To do this, change the selection of GROUP_LOOKUP to:

    SELECT Seq_number INTO seqNumber FROM GROUP_LOOKUP WHERE ABBREVIATION = p_group_name for an updated VERSION OF the SEQ_NUMBER;

    and move this to be the first thing that did the procedure - before it has CASE_RECORD lines.

    In the case when p_group_name is set to null, you have some object to be locked. I think the best you can do is to lock the entire table GROUP_LOOKUP:

    the table lock in exclusive mode GROUP_LOOKUP wait 100;

    The '100 expectation' means that he will wait until 100 seconds before giving up and trigger an error. in practice, that is expected to only wait a moment.

    Exclusive mode allows others to read, but not to update the table.

    UPDATES and the LOCK of the TABLE will be updates of other sessions wait for this transaction to validate. Queries from other sessions are not affected.

    The locks are released when you commit or roll back.

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

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

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

  • XMLTable to extract columns with conditional path does not

    Hello

    I am on 11.2.0.3 and I need to extract columns on a section of XML with conditions on, but I get "ORA-00907: lack the right parenthesis", so I think that the way I go about it is not supported or that I have somehow the wrong syntax or something.

    This is a very simplified what I'm trying to do (there could be several different entries in the < sets1 > and < sets2 > sections and they might be in different orders, is not as if I can always choose the first or the last):

    with sample_data as (select 1 id,
                                xmltype('<root>
                                           <sets1>
                                             <set1><set_name>name1</set_name><set_val>val1</set_val></set1>
                                             <set1><set_name>name2</set_name><set_val>val2</set_val></set1>
                                           </sets1>
                                           <sets2>
                                             <set2><set_name>name3</set_name><set_val>val3</set_val></set2>
                                             <set2><set_name>name4</set_name><set_val>val4</set_val></set2>
                                           </sets2>
                                         </root>') xml_doc from dual)
    select *
    from   sample_data sd,
           xmltable('<root>' passing sd.xml_doc
                    columns col1 varchar2(10) path 'sets1/set1[set_name=''name1'']/set_val',
                            col2 varchar2(10) path 'sets1/set1[set_name=''name2'']/set_val',
                            col3 varchar2(10) path 'sets2/set2[set_name=''name4'']/set_val') x;
    

    What I'm trying to get:

    COL1  COL2  COL3
    ----  ----  ----
    val1  val2  val4
    

    I know that I could separate the < set1 > and < set2 > nodes in their own xmltypes xmltable on it and then join them and make the necessary pivoting, etc., but when I try to start that against only 1000 lines, db do not love and ended my session! Therefore, I'm looking for a more elegant way to do it.

    Is there a way to do this in a XMLTABLE? Pointers are very welcome!

    It solves your problem of sample request and you get the output that show you.

     with sample_data as (select 1 id,
                                 xmltype('
                                            
                                              name1val1
                                              name2val2
                                            
                                            
                                              name3val3
                                              name4val4
                                            
                                          ') xml_doc from dual)
     select x.*  -- change
     from   sample_data sd,
            xmltable('/root' passing sd.xml_doc  -- change
                     columns col1 varchar2(10) path 'sets1/set1[set_name="name1"]/set_val',  -- change
                             col2 varchar2(10) path 'sets1/set1[set_name="name2"]/set_val',  -- change
                             col3 varchar2(10) path 'sets2/set2[set_name="name4"]/set_val') x;  -- change
    

    As you can see, I've marked the lines that I've changed.  The error you saw came to use two single quotes in the COLUMN XPath instead to use double quotes.  Then I changed the XPath expression in the XMLTable brackets as well.

    I'm confused on what the columns you really want overall, in terms of how you know which values you want, or did you mean that you want something random sets1 and sets2.

    You store the XML file in a column of XMLType SECUREFILE BINARY, right?  It seems that you made previous visits, but just double check.

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

  • 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

  • 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

  • Reactive layouts: publish multiple Sites with conditional Builds and which connect

    I hope that someone can provide a simple solution to publish problems I've had with adapted presentations when you try to publish several sites with conditional builds. Essentially, I want to be able to have an index page that links to one of the two variants of the published sites that I called 'General' and 'specific '. When I click on the 'general' link I want to not open the site which was published with a conditional for all these subjects compilation labeled as 'general' and when I click on the 'link' want it to open the site which was published using a conditional version for 'specific '.

    Here are the steps I took to create sites and can't seem to get to bind correctly:

    Table of contents, topic Creation and tagging content

    1. Creates a Table of contents.
    2. Added 2 topics in the Table of contents. The first topic, I called "general" and the second issue I called, 'specific '.
    3. I then click with the right button on the "general" and selected subject Tag to build conditional apply. From there, I've created a new tag called "General".
    4. I repeated this process to create the specific tag, but do a right-click on the 'specific' theme and the creation of a new tag called "specific".

    Layouts reactive and edited the sites based on the conditional tags

    1. Created sensitive presentation using the standard layout and content generated without any conditional builds.
    2. Duplicated sensitive put in page and gave him the content of 'general' then it is generated using the conditional, "General" version If the finished publication published content has shown that the 'general' subject, as expected.
    3. I then repeated the same process for the specific content and content using the version parole, generated 'specific '. When over content published showed that the subject marked as 'specific' as expected.

    Added an Index page to the table of contents

    1. Created a new topic to serve as the launch page.
    2. Added a 'general' hyperlink called for the launch of the general "theme found in the general publishes from the resource manager.
    3. Added a hyperlink called 'specific' to the launch of the general "theme found in the specific issues from the resource manager.
    4. I then republish the sensitive standard layout site.

    From this point, it gets stuck and won't open properly published Web sites. I don't know why it won't launch hyperlinks correctly. Is there something I'm missing? Let me know if you do not want to see my files. I will be gladly their.

    OK, thanks a lot for the capture screen. They help more than you realize.

    So here's one of the biggest mistakes I think that you have done so far. You use the resource manager to link to published results. If it is technically possible to do, I'm pretty sure Adobe never planned for it to be used this way.

    It may help to think in terms of creation of food products. I have long considered as RoboHelp to be very much like working in my kitchen. All consumables (heading text in the headings, images, HTML pages, etc.) are just as raw ingredients. (Eggs, milk, flour, etc.). The places of storage (hard drive) it's like the pantry and the fridge. And RoboHelp provides facilities to easily combine ingredients to create the different recipes.

    This next bit will be somewhat exaggerated, but bear with me. Maybe you have one or more neighbors and all you want to share some common "ingredients". If you set the things where each of you have access to a wine cellar and a shared refrigerator. Maybe you do a Dutch sauce killer. You create it and place in the refrigerator, then your other participants have access through the common "fridge". This is exactly what the resource manager is intended to help.

    Now assume that you create something like cookies chocolate chip and you keep in the refrigerator. Well, that's fine, but you don't want to use cookies to chocolate chip already baked in a recipe that might call for cookie dough. But that's what happens when you take an exit and place in a place intended for raw ingredients. And you will see the strange behavior. Prepare for these cookies chemically changes them so that cookies already are significantly different from the dough used to create them. Similarly, you don't want to take one or more output files and reuse in a project source.

    So in your case, you run an index file and that fires events to produce the output. All should be well. But when you click on the links to open topics, topics are intended to show up more in the right panel. Think of the picture of how works of image on a TV. The moment that link you to something intended to fill the screen, he is forced into this smaller area on the right. If you end up with what you see in the last picture.

    I suggest the following steps.

    First, REMOVE your resource manager exits.

    REMOVE all links that can point here.

    Output records where people will consume copy your projects. (The web server)

    Then figure either the parent (.. /.. / somefolder/somefile.htm) path to other systems or the absolute path (http://www.whatever.com) and to link the projects in this way.

    Sorry, but without seeing the installation of first hand, it is difficult to say what should be these paths.

    I hope this was helpful... Rick

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

Maybe you are looking for

  • reverse order of the playlist

    I recently made a playlist with all my songs in order of when I have them but they are out of order and I just want to reverse the order, I can't sort by date added, because I jumped on top of spotify and have downloaded chunks of apple's music I had

  • Windows update fails with error Code: 0 x 80070645

    After the new installation of XP Pro SP3 all Updates MS have now successfully other thanMicrosoft .NET Framework 3.5 Service Pack 1 and the .NET Framework 3.5 Family Update for versions of .NET 2.0 to 3.5 (KB951847) x 86. Installation of the stand-al

  • Why the hp officejet pro 850 always clean heads printer etc etc on start up?

    Hi my printer always seem it self check on every time I start it. It checks the parts themselves, calibration and printer heads. It takes about 1 minute ot more cela and offers in the menu, it might take longer than that. Certainly there is a way to

  • IPSec tunnel do not come between two ASA - 5540 s.

    I've included the appropriate configuration of the two ASA lines - 5540 s that I'm trying to set up a tunnel of 2 lan lan between. The first few lines show the messages that are generated when I try to ping another host on each side. Did I miss somet

  • How can I prevent my computer from auto lock?

    I think that my settings were part of a group security policy (laptop).  I have administrative rights on the laptop, and in the past, I have simply outweigh the policy setting "on RESUME, password screen" (or changed the deadline to 24 hours). Howeve