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;

Tags: Database

Similar Questions

  • Update of column with the same value of the column

    Hello

    I have a scenario like below:

    SRC TAR RSRC FLG
    EN101 1001 1001 Y

    1002 EN101 N
    1003 EN101 N

    Since then, my flag is there for the first record, I have identical RSRC of the CBC. Now, I need RSRC 1001 value for 2 other records as the value of these recordings is N and the target is EN101.

    All of the suggestions.

    Thank you

    merge into your_table t

    a_l'_aide_de)

    Select

    tar

    min (rsrc) rsrc

    from your_table

    where flg = 'Y '.

    Group of tar

    ) u

    on (t.tar = u.tar)

    when matched

    update the value t.rsrc = u.rsrc

    where t.rsrc is null

  • An update on an index column with the same value generates an index to the top

    An update on an index column with the same value generates an update of the index?


    Thank you

    In addition to my previous answer, see also

    http://orainternals.WordPress.com/2010/11/04/does-an-update-statement-modify-the-row-if-the-update-modifies-the-column-to-same-value/

    Riyaj Shamsudeen has this to say:
    "+ We have an index on this column v1 and we update this column indexed too." Oracle was updating the indexed column? N ° if the values match the level of the indexed column, then the code of RDBMS isn't up-to-date index, a feature for optimization again. Only the row of table is updated, and the index is not updated. + "

    Hemant K Collette

  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • 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

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

  • Documentation about adding column with the DEFAULT value.

    Hello

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_3001.htm#i2198241

    < quote >
    If you add a column, then the initial value of each row in the new column is NULL unless you specify the DEFAULT clause. In this case, Oracle database updates each row in the new column with the value specified for the DEFAULT value. This update operation, in turn, triggers AFTER UPDATE triggers defined on the table.
    < quote >

    I am not able to understand the emphasis on the part AFTER UPDATE while the column with DEFAULT values addition triggers both BEFORE and AFTER triggers defined on UPDATE.

    According to the documents of 11 g

    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/statements_3001.htm#i2133105

    n.m. (u) r only changes with the NON NULL columns, but focus on AFTER UPDATE is still there. No trigger defined on the fire of the update in this case.

    This insistence is intended? If not, IMO, it should be changed.

    Kind regards

    Hi Sissi. After further discussion, we have added some information about a change in behavior. Here is what says the next version of the doc:

    When you add a column, the initial value of each row in the new column is null.

    * If you specify the DEFAULT clause for a column NOT NULL, then the default value is stored as metadata, but the column itself is not populated with data. However, the following queries that specify the new column are rewritten so that the default value is returned in the result set.

    This optimized behavior differs from earlier versions, when as part of operation ALTER TABLE Oracle database updated every line in the newly created with the default column and then fired defined update triggers on the table. In this release, no trigger is triggered because the default value is stored only in the form of metadata.

    * If you specify the DEFAULT for a nullable column clause, then the default value is added to existing lines under this ALTER TABLE statement, and any update triggers defined on the table are activated. This behavior also means if you change a NOT NULL column with a default value to be nullable.

    Hope that helps to clarify the matter further.

    Kind regards
    Diana

  • update other items with the same value when when the column contains Y

     
    CREATE TABLE TEST 
       (     "QUATINTY" NUMBER(17,2), 
         "AMOUNT" NUMBER(17,2), 
         "ERRORRED" VARCHAR2(16 BYTE), 
         "PO" VARCHAR2(12 BYTE), 
         "LINE" VARCHAR2(10 BYTE), 
         "SEQ" VARCHAR2(14 BYTE), 
         "INVOICE" VARCHAR2(16 BYTE)
       ) 
    
    Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('123',5,50,'Y','1','1','inv1');
    Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('123',5,50,null,'1','2','inv1');
    Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('125',5,50,null,'1','1','inv2');
    Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('125',4,50,null,'1','2','inv2');
    If you notice the table above which im trying to Edifier is updated the errorred column with 'Y' if the po and invoice are the same and have a 'Y' on the wrong column.
    in other words, I should finish with "Y" in the column for INV1 errorred.
    Can someone point me in the right direction, I can't for the life of me figuered it out.

    Hello

    Here's one way:

    UPDATE     test
    SET     errorred     = 'Y'
    WHERE     NVL (errorred, 'N') != 'Y'
    AND     (po, invoice)          IN (
                              SELECT  po, invoice
                         FROM      test
                         WHERE      errorred  = 'Y'
                               )
    ;
    

    This requires that the po and invoice are not NULL. If a column can be NULL, then the solution might be a little messier, according to the results you want, but only a little. Post some sample data (with null values) which shows what types of situations, you need manage, and the results of the SAMPLES.

  • ComboBox - updated database with the ID associated with the selected value

    Hello, first off I am a newbie to developing Flash Builder with PHP, so any help would be mucho appreciated.

    I want to update my database with an id associated with a seletcted value in a combobox

    -I'll create a combox and asociate to a data service that retrieves all possible values

    -With the help of selectedItem, I'm able to the value of the ComboBox to the value associated with the default data object

    -To submit, I want to update the database, not with the value directly, but with its associated id.

    -The list of values are a list of locations with a specific id.

    Here is my code

    ComboBox on a form

    "" < s:Form includeIn = "LocationAdd, LocationUpdate"x ="52" y ="320" defaultButton = "auLocnBtn{}">

    "< s:FormItem label = 'provider ID" "" >

    "" < s:ComboBox id = "spidComboBox" selectedItem ="locations.snam{}" includeIn = "LocationUpdate'x ='97" y ="539"

    creationComplete = "comboBox_creationCompleteHandler (event)" labelField ="name" > ""

    " < s:AsyncListView list =" getSplResult.lastResult{}"/ > "

    < / s:ComboBox >

    < / s:FormItem >

    " < s:Button id ="auLocnBtn"label ="Submit"click ="auLocnBtn_clickHandler (event)"label. LocationUpdate ="Update"tag. LocationAdd ="Add"/ > "

    < / s:Form >

    protected function auLocnBtn_clickHandler(event:MouseEvent):void

    {

    Locations.SPID = parseInt (spidComboBox.selectedItem);

    updateLocationResult.token = locationService.updateLocation (rentals);

    }

    This code will move to the selected item, in this case locations.snam. However, getSpl returns two fields - name and id. I want id associated with locations.snam to use to update the database.

    Do this in php and html is really straight forward, because there is a < value > property that allows me to pass the ID. Something similar in flash builder? I spent hours on this... Please don't laugh, I said I was new on FB!

    See you soon,.

    Brian

    Okay understood outside, what I had to do was

    protected function auLocnBtn_clickHandler(event:MouseEvent):void

    {

    Locations.SPID = parseInt (spidComboBox.selectedItem.spid);

    }

    that is the reference object properties... FB with PHP is great!

    This can be closed.

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

  • The research of a column with comma separated values with ora-text

    I use the Oracle 11 g 2 XE and Oracle Text to a web search engine.

    I've now created and text indexed a CLOB keywords column that contains words separated by spaces. This allowed me to expand the search, as Oracle Text returns the rows that have one or more keywords that are stored in this column. The contents of the column are visible to the user and serves to 'expand' the search. This does not work as expected.

    But now I need support several words or even sentences. With the current configuration, Oracle Text will only search for each keyword. How should I store the phrases and configure Oracle text so that it will search entire sentences (exact match is better, but the partial match is fine too)?

    Example of content column of two lines (values separated semicolon):
    "Hello, Hello; y at - it anyone out there? Nope; »
    "the just; basic facts; »
    I found a similar question: looking for a column with values separated by commas, except that I need a solution for Oracle 11 g with it's freetext search.

    Possible solutions:
    1st solution: I thought to redraw the DB as follows. I would like to make a new array of keywords (pkID NUMBER, nonUniqueID NUMBER, singlePhrase VARCHAR2 (100 BYTE)). And I want to change the column previous keyword to KeywordNonUniqueID, holding the ID (instead of a list of values). At the time of the research I had INNER JOIN with the new keyword table. The problem with this solution is that I will get several lines containing the same data except for the sentence. I guess this will destroy the ranking?

    2nd solution: is it possible to store sentences as an XML in the column key of origin and somehow say Oracle text to search for in the XML?

    3rd solution: separate individual phrases with spaces, but replace the spaces in sentences with the underscore or something (making a single word). If a phrase "why Hello there, Johnny!" is saved as "Why_hello_there, _Johnny!

    4th solution?:

    Note that, generally, there is a lot of sentences (less than 100), nor that they will be long (one sentence will be up to 5 words).

    Also note that I am currently using CONTAINS, and needs some of its operators, to my full-text searches.

    When you talk about "phrase", do you mean "a list of words separated by a comma other sentences?

    Isn't that the definition of "sentence" used by Oracle Text, where it simply means "a list of words in the order defined."

    If I understand your requirement, you want to have data such as:

    "aa bb cc dd".
    "aa ee dd ff.

    and give priority to the first on the second if someone looking for "dd".

    First, to conduct research in the comma separated list, you should look for in a section. You can either explicitly define sections of field such as
    AA bb cc dd
    Or you can use the PHRASE special section and set the sentence delimiters correctly. This is done with the attribute BASIC_LEXER punctuation

    Then you have the number you want to find only words where they are the only words in the section. That's the same problem, I address in the last post of this forum entry:
    Contains: match exactly

    Our solution will be substantially the same, some surrounding text with special markers, and then prioritize a phrase search with these special markers each side of the word.
    We need to do a treatment some additional, although, as we need to surround each "sentence" (in your terminology) with special markers. I did it by surrounding the text with "XX1"... Condition2"then by replacing every comma with"Condition2, XX1"as part of a MULTI_COLUMN_DATASTORE:

    drop table names;
    create table names (id number primary key, text varchar2(50));
    
    insert into names values( 1, 'just and kind, kind and loving' );
    insert into names values( 2, 'just, kind' );
    
    exec ctx_ddl.drop_preference  ( 'mylex' )
    exec ctx_ddl.create_preference( 'mylex', 'BASIC_LEXER' )
    exec ctx_ddl.set_attribute    ( 'mylex', 'PUNCTUATIONS', ',' )
    
    exec ctx_ddl.drop_preference  ( 'mcds' )
    exec ctx_ddl.create_preference( 'mcds',  'MULTI_COLUMN_DATASTORE' )
    exec ctx_ddl.set_attribute    ( 'mcds', 'COLUMNS', '''XX1 ''||replace(text, '','',''XX2, XX1'')||'' XX2''' )
    
    exec ctx_ddl.drop_preference  ( 'mywl' )
    exec ctx_ddl.create_preference( 'mywl', 'BASIC_WORDLIST' )
    exec ctx_ddl.set_attribute    ( 'mywl', 'SUBSTRING_INDEX', 'YES' )
    
    create index namesindex on names(text)
    indextype is ctxsys.context
    parameters( 'datastore mcds wordlist mywl' )
    /
    
    select score(1),id,text from names where contains( text, '
    
      
        
           XX1 kind XX2 
           kind
        
      
    
    ', 1) > 0
    order by score(1) desc
    /
    

    Output of this is:

      SCORE(1)        ID TEXT
    ---------- ---------- --------------------------------------------------
         52         2 just, kind
          2         1 just and kind, kind and loving
    
  • How can I replace the value of the column with a particular value in SQL

    Hi all

    Is someone can you please tell me how can I format my output with the replacement of a column value with a specific value that really depends on the current value of the column

    I am executing the following SQL statement

    Select state, count (id) from < table_name > where composite_dn = < composite_dn_name > Group by State;
    My current performance is:

    State Instance number
    1 3
    3 28

    I want to replace the value in the State column as follows

    No.OfInstances State
    3 filled
    28 faulted

    I want '1' to be reppaced of 'Done' and '3' is replaced by 'Faulted. '

    Is is possible with SQL or PL/SQL, if it is then how I can achieve this required. Help, please!

    Thanks in advance!

    Published by: Roshni Shankar on October 27, 2012 12:38 AM

    Hi Claude,.

    I guess this CASE clause can be simulated by a DECODE and also it is very easy to use.
    See - http://www.techonthenet.com/oracle/functions/decode.php

    select decode(t1.state,t2.state_id,t2.state_name), t1.count_id
    from  t2, (select state,count(id) count_id
     from 
     where composite_dn= 
    group by state) t1
    where t1.state = t2.state_id;
    

    HTH
    Vanessa B.

    Published by: Vanessa B on October 27, 2012 14:02
    -link added

    Published by: Vanessa B on October 27, 2012 14:19
    -added code sample

  • 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

  • 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

Maybe you are looking for

  • Everyone has an effect/invoice of systweak without permission?

    My wife received an invoice to thank for his payment to Systweak. Payment was made (not seen funds gone yet) it has activated just yesterday on a visa card. We do not know this company. We have never been on their website and we certainly has not "bu

  • Is it possible to use the Acer restore disks on a new hard drive?

    The hard drive on my Aspire 5251 appears to be dead. He was behaving erraticly and we tried a full restore via the program eRecovery a couple of times and it is always wrong (error 0x45d). We also tried discs that we did when the laptop is new with n

  • How can I download and reinstall the games window

    my games windows vista folder is empty, how do I reinstall, the computer was purchased from best buy and didn't come with program records.

  • F340

    I don't want the printer to print the last page first.  How can I print the first page first?

  • InDesign CC 2015.4 - CRASH

    Does anyone else have this problem. Legit... it's random. I am a person magazine and I can be working and boom - gone.It's happened for a few months. I'm relatively new to Mac so... kind of lost.Thank you