Update statement as well as a number

I have a table with specific data in it and I need to change a generic name. The field is question is VARCHAR2 (4000 BYTE). What I need the values to be, is something like 1 Agency, agency 2, etc. Now a single table count 184 values so I could do it manually, but another table has more than 10,000, which would take much too long.

Now the ideal situation would be, there is a primary key in the table which is a number. If there is a way that I could line them up the values would be as Agency (primary key number). It would be great.

Thank you

Something like:

update my_table
set my_column = my_column||to_char(pk_column)
where ...

If you want a fixed text instead of what is already in the column, and then use a constant string where my_column I in the update. If you do not have a numeric PK column, you can use rwnum instead of pk_column.

John

Tags: Database

Similar Questions

  • SQLite Update statement

    I have a database in my application, and part of it (obviously) will require the user to update the database with the current information.

    There are 24 columns of the table, and I have my update function works almost 100%, except that there are two drop downs, and when the user updates the record individual everything that is selected in the fall of two downs, is applied to all records.

    My update statement is like this:

    var statement:SQLStatement = new SQLStatement();statement.sqlConnection = connection;statement.text = "UPDATE TABLE SET " +      "OneFish=?, " +       "TwoFish=?, " +       "RedFish=?, " +       "BlueFish=?, " +          // CONTINUES AS TEXT INPUTS DOWN TO       "DropDown1=?, " +     "DropDown2=?, " +          // FEW MORE TEXT INPUTS THEN                "WHERE RECORD_ID=?";       statement.parameters[0] = OneFish.text;       statement.parameters[1] = TwoFish.text;       statement.parameters[2] = RedFish.text;       statement.parameters[3] = BlueFish.text;          // CONTINUES AS TEXT INPUTS DOWN TO       statement.parameters[17] = DropDown1.selectedItem;        statement.parameters[18] = DropDown2.selectedItem;          // FEW MORE TEXT INPUTS THEN        statement.parameters[23] =                FishOption.selectedItem.RECORD_ID;                statement.addEventListener(SQLEvent.RESULT, updateWorked);                statement.addEventListener(SQLErrorEvent.ERROR, updateFailed);                statement.execute();
    

    ALL updates day very well and shown to the a specific RECORD_ID. However, the decline in the bottom change overall.

    This does not happen on my service of "addFish". Someone out there have any ideas why this is?

    Update: It isn't my SQL. If I close the application and then go back, the changes show correctly. The drop down menus are simply not refreshing properly after the update of the database.

    J.Rab!

    I literally JUST thought out and sat next to the woman to rejoice with the laptop on my lap! Then the BlackBerry made his small notification and I said out loud, "oh look, it's probably somebody tell me what I did wrong before that I could update!

    Had dinner and a record label with a look at it to understand.

    To display the resulting data & update fields, I was setting the command prompt from the drop down menus! I went my output and changed function use the selectedItem and success!

    I also forgot to include a refreshTheDatabase(); at the end of my updateFunction() function call;

    I hit a brick wall with this for several hours this afternoon and I can't believe it was that simple! I should have got up and walked away earlier!

  • Commit to taking a lot of time for the update statement to bulk - 11 GR 2

    Hi team,

    We have a source table, which is the main table for our application.

    When I commit a transaction after update block, it takes long about 2 to 4 minutes.

    I don't understand why it takes too long...

    Could you please help me on this fix, please...

    It's the details on the table,

    Total number of records: 35 M record

    Validation interval: 500 records / commit

    Total scores: 3

    total number of columns: 95 - including primary, unique and foreign key columns (all columns will be updated for each update because update from the app online)

    Total no of the foreign key columns: 12

    Unique key column: 1

    Total index: 27 ( including the key index foreign 12 + 1 + 1 index of primary key Unique key index )

    example of update statement,

    UPDATE DIRECTORY_LISTING_STG
    SET
      COLUMN_1 = :VAL_1
      .
      .
      .
      COLUMN_94 = :VAL_94
    WHERE RECORD_KEY = :P_KEY_VAL;
    
    

    The table is.

    Plan hash value: 2997337465
    
    --------------------------------------------------------------------------------------------
    | Id  | Operation          | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------
    |   0 | UPDATE STATEMENT   |                       |     1 |   308 |     3   (0)| 00:00:01 |
    |   1 |  UPDATE            | DIRECTORY_LISTING_STG |       |       |            |          |
    |*  2 |   INDEX UNIQUE SCAN| XPKDLS_STG_PARTPN     |     1 |   308 |     2   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("RECORD_KEY"=TO_NUMBER(:P_KEY))
    
    

    Details of the database,

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    "CORE 11.1.0.7.0 Production"
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    
    

    Thank you

    RAM

    2793617 wrote:

    Hello

    I am updating table via an application using Hibernate jdbc connection online.

    If the update statement will be sent to the database in a pack of 500 documents (batch update).

    Thanks Ram

    line-by-line UPDATE is slow by slow transformation

    In Oracle no other session can 'see' upgrade from uncommitted changes.

    The only way to significantly reduce the elapsed time is to have only 1 UPDATE & 1 COMMIT!

  • Update statement

    Hi friends,

    Need your help with an update statement.

    Update t set t.icode int_tab =.

    (select ac.icode in the ac_tab ac, ed edition

    where ac.current_code = ed.unit)

    where ed.process_no = t.action_no);

    where ed.process_no = t.action_no

    *

    ERROR on line 4:

    ORA-00904: "ED". "" PROCESS_NO ": invalid identifier

    Basically, we need to update int_tab.icode with ac_tab.icode where ac_tab.current_code = edition.unit

    Thank you very much

    I suggest you MERGE. Inside () I call "source" can be controlled carefully. And then you can easily do the UPDATE

    No funny Executive plans and if he SELECT jobs, UPDATE works as well.

    MERGE into the target int_tab

    USING (SELECT t.rowid, rid, ac.icode,

    Of ac_tab ac

    Join IN-HOUSE ed Edition

    ON ac.current_code = ed.unit

    Join IN-HOUSE int_tab t

    ON ed.process_no = t.action_no

    WHERE t.icode! = ac.icode

    and t.icode is not null) source

    on (target.rowid = source.id)

    WHEN MATCHED

    THEN UPDATE set target.icode = source.icode;

  • Update statement can be used depending on the result cache?

    Hi all

    I stumbled on an interesting question. UPDATE statement is used in the following function, even if the feature is created RESULT_CACHE. It seems illogical. I was wondering, is it possible?

    If so, why RESULT_CACHE is used?  Because it means "do not execute the function, look for the result of the hash table and return the results to the user ' if the UPDATE statement, so doesn't mean it should run for each call and use with RESULT_CACHE and UPDATE/DELETE/MERGE is illogical or wrong?

    Thanks for your help.

    FUNCTION to CREATE or REPLACE plch_get_data (FULL id_in)

    RETURN VARCHAR2

    RESULT_CACHE

    IS

    BEGIN

    Dbms_output.put_line ('run');

    UPDATE plch_data

    SET nm = UPPER (nm)

    WHERE id = id_in;

    COMMIT;

    RETURN "SUPERIOR."

    END;

    /

    Yes, it's the challenge of PL/SQL quiz - and the point of the quiz is only automatic relies on parsing by Oracle only supports arrays of account that is QUESTIONED.

    The tables that are affected by DML not a query as an update do not figure in automatic invalidation of a cache.

    I was hoping that the explanations given in the questionnaire itself would not lead to a thread - rather it would provide a pleasant and clear answer. So feel free to let me know if you think otherwise.

    As to why Oracle would let you include DML not a query inside a function of caching of result, well... I can easily accept that you shouldn't do this - in general. But I don't see that we should make it impossible. It would probably be a good candidate for an another PLW (PL/SQL warning), as in:

    "Non-requetes DML in a result caching function will not affect caching and can result in unexpected results."

  • Helps when a special character and is included in the update statement

    Hi gurus,


    Please suggest me here. Your help is greatly appreciated.

    Am wririting an update statement on a column called Phone_num.description varchar2 (40).


    Here is my update statement:


    UPDATE Phone_num
    DESCRIPTION SET = "Beta - EMV / not for the purpose of Production."
    WHERE DIAL_NUMBER = 18662307528
    AND DESCRIPTION =' to & VERIZON';


    Here is the structure of the table:

    Phone_num. Description varchar2 (40)
    Phone_num. DIAL_NUMBER Number (11)

    Sample data:


    So when I run the sql script it pop-up is to highlight.

    Please suggest how I can handle this.

    Hello

    As John said, the easiest thing is just to disable the functionality of substitution of variables, saying:

    SET DEFINE OFF

    before the statement.  If you need to re - enable this feature, then tell

    ALL SET ON

    just after the statement.

    If you can't do that, then break the literal string in 2 parts immediately after the & character, like this:

    UPDATE Phone_num

    DESCRIPTION SET = "Beta - EMV / not for the purpose of Production."

    WHERE DIAL_NUMBER = 18662307528

    AND DESCRIPTION = ' to &'. | "VERIZON";

    You can't have a substitution variable whose name starts by ', then SQL ("more does not interpret &" as meaning a substituton variable.)

  • line blocking during the update statement


    Hello

    Using Oracle 11 g 2. If I call the following update statement of meeting A, meeting A locks the line until a statement commit / rollback is emanating from the session has. If the session B calls the same statement was updated and the same line, session B will have to wait until the lock is released in the session. However, application developers are expressed in terms of discussions. Would it be possible that the update statement is called in the same session by several requests? If so, the case statement can be evaluated without the line being locked which could lead to erroneous results? Trying to keep this short message.

    tableA has column (number of key, primary) and columnB (number)

    {

    Update tableA

    Define columnB = case when columnB = 3 then

    4

    When columnB = 4 then

    5

    on the other

    columnB

    end

    When columnA = 6;

    }

    2 applications (almost at the same time) in the same session could assess columnB 3. The goal would be the first query sets in column 4 and the second request sets in column 5.

    > However, application developers are expressed in terms of discussions.

    Of course, they are...

    But each application thread will have its own dedicated database session.

  • problem by making an update statement

    Hi all
    I should write an update statement
    These tables: country: name, code, population, nextyearr_population...
    nextyear_population is empty, first, I should get population_growth of the picture of the population, then compute the year population next according to population and population_growth corrent

    population: country (in fact no code name of the country), population_growth,...

    So I wrote and I got this error
    Error starting at line 1 in command:
    
    update country c
    set c.nextyear_population=(c.population+ ((c.population*(select pop.population_growth from population pop join country co on co.code=pop.code))/100)
    )
    where country.code=population.country
    Error at Command Line:4 Column:20
    Error report:
    SQL Error: ORA-00904: "POPULATION"."COUNTRY": invalid identifier
    00904. 00000 -  "%s: invalid identifier"
    *Cause:    
    *Action:
    --------------------------------------------------------
    --  File created - Wednesday-May-15-2013   
    --------------------------------------------------------
    --------------------------------------------------------
    --  DDL for Table COUNTRY
    --------------------------------------------------------
    
      CREATE TABLE "intern"."COUNTRY" ("NAME" VARCHAR2(40), "CODE" CHAR(2), "CAPITAL" VARCHAR2(40), "PROVINCE" VARCHAR2(40), "POPULATION" NUMBER, "AREA" NUMBER, "NEXTYEAR_POPULATION" NUMBER) 
     
    
       COMMENT ON COLUMN "intern"."COUNTRY"."NAME" IS 'the country name'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."CODE" IS 'the internet country code (two letters)'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."CAPITAL" IS 'the name of the capital'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."PROVINCE" IS 'the province where the capital belongs to'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."POPULATION" IS 'the population number'
     
       COMMENT ON COLUMN "intern"."COUNTRY"."AREA" IS 'the total area'
     
       COMMENT ON TABLE "intern"."COUNTRY"  IS 'the countries of the world with some data'
    REM INSERTING into intern.COUNTRY
    SET DEFINE OFF;
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('Andorra','ad','Andorra la Vella','Andorra la Vella',69865,468,null);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('United Arab Emirates','ae','Abu Dhabi','Abu Dhabi',2523915,82880,null);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('Afghanistan','af','Kabul','Kabul',28513677,647500,null);
    
    
    
    
    --------------------------------------------------------
    --  File created - Wednesday-May-15-2013   
    --------------------------------------------------------
    --------------------------------------------------------
    --  DDL for Table POPULATION
    --------------------------------------------------------
    
      CREATE TABLE "intern"."POPULATION" ("COUNTRY" CHAR(2), "POPULATION_GROWTH" NUMBER, "INFANT_MORTALITY" NUMBER) 
     
    
       COMMENT ON COLUMN "intern"."POPULATION"."COUNTRY" IS 'the country code'
     
       COMMENT ON COLUMN "intern"."POPULATION"."POPULATION_GROWTH" IS 'population growth rate (percentage, per annum)'
     
       COMMENT ON COLUMN "intern"."POPULATION"."INFANT_MORTALITY" IS 'infant mortality (per thousand)'
     
       COMMENT ON TABLE "intern"."POPULATION"  IS 'information about the population of the countries'
    REM INSERTING into intern.POPULATION
    SET DEFINE OFF;
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('ad',0.95,4.05);
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('ae',1.54,14.51);
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('af',4.77,163.07);
    Thanks in advance

    I'm using oracle11g and ubuntu 12


    best, david
    update  country c
       set  nextyear_population = population + population * (select pop.population_growth from population pop where c.code = pop.country) / 100
     where  code in (
                     select  country
                       from  population
                    )
    /
    

    SY.

  • Helps with the UPDATE statement

    Hello

    I have a table like this:
    create table test
    (id number,
    stat number,
    id_num number);
    data in the table:
    insert into table test (id,stat,id_num) values (1,112,'');
    insert into table test (id,stat,id_num) values (1,123,'');
    insert into table test (id,stat,id_num) values (2,134,'');
    insert into table test (id,stat,id_num) values (2,111,'');
    insert into table test (id,stat,id_num) values (3,112,'');
    insert into table test (id,stat,id_num) values (4,111,'');
    insert into table test (id,stat,id_num) values (4,12,'');
    insert into table test (id,stat,id_num) values (4,11,'');
    I want to update the column id_num with serial number under the same ID.
    Below is the table with coloumn successfully updated.
    insert into table test (id,stat,id_num) values (1,112,1);
    insert into table test (id,stat,id_num) values (1,123,2);
    insert into table test (id,stat,id_num) values (2,134,1);
    insert into table test (id,stat,id_num) values (2,111,2);
    insert into table test (id,stat,id_num) values (3,112,1);
    insert into table test (id,stat,id_num) values (4,111,1);
    insert into table test (id,stat,id_num) values (4,12,2);
    insert into table test (id,stat,id_num) values (4,11,3);
    Can someone give me a hint how to remove this?

    Thank you very much for your help!

    user13071990 wrote:
    Manik which is not a good solution because dat_document can also be duplicated.

    Alberto is no uniq key in the table, which is the main problem.

    It is not a good way to get the table without unique keys.

    To work around the problem, I suggest that, despite the fact that I do not use virtual ROWID.

    I did a test by inserting a date twice for the same id

    insert into test (id,dat_document,id_num) values (4,to_date('01.07.2012','dd.mm.yyyy'),'');
    

    Now, I used:

    MERGE INTO test a
         USING (SELECT rowid
                     , ROW_NUMBER () OVER (PARTITION BY id ORDER BY dat_document) AS val
                  FROM test) b
            ON (a.rowid = b.rowid)
    WHEN MATCHED
    THEN
       UPDATE SET id_num = val;
    
    SELECT *
      FROM test
    ORDER BY id, dat_document;
    
            ID DAT_DOCUMENT              ID_NUM
    ---------- --------------------- ----------
             1 01-01-2012 00:00:00            1
             1 01-02-2012 00:00:00            2
             2 01-03-2012 00:00:00            1
             2 01-04-2012 00:00:00            2
             3 01-05-2012 00:00:00            1
             4 01-06-2012 00:00:00            1
             4 01-07-2012 00:00:00            2
             4 01-07-2012 00:00:00            3
             4 01-08-2012 00:00:00            4
    

    Kind regards.
    Al

  • Handful of division by zero error in the update statement

    My dear welcom

    How and I overcame this problem in my update statement
    for exwmple, it comes to the table
    CREATE TABLE TEST4
    (
    A1 NUMBER,
    A2 NUMBER OF,
    A3 NUMBER
    )

    Insert into TEST4 a1, a2, values (15.3);
    Insert into TEST4 a1, a2, values (9.3);
    Insert into TEST4 a1, a2, values (12.0);

    commit;


    now, I'm trying to update the column a3 in Division a1/12

    Start
    update set of test4
    A3 = a1/a2;
    exception
    WHEN ZERO_DIVIDE THEN
    update set of test4
    A3 = 0;
    end;
    After you validate THE VALUE of A3 = 0;

    Can any onle help me


    I use oracle 10g R2
    Thanks in advance
    SQL> select  *
      2    from  test4
      3  /
    
            A1         A2         A3
    ---------- ---------- ----------
            15          3
             9          3
            12          0
    
    SQL> update  test4
      2     set  a3 = case a2 when 0 then 0 else a1 / a2 end
      3  /
    
    3 rows updated.
    
    SQL> select  *
      2    from  test4
      3  /
    
            A1         A2         A3
    ---------- ---------- ----------
            15          3          5
             9          3          3
            12          0          0
    
    SQL> 
    

    SY.

  • Decode function in the Update statement

    Hi all

    I'm writing a query where I can update a pastdue_fees column in a table of book_trans based on a difference between the return_dte and due_dte columns.

    I use Oracle SQL. That's what I have so far for my decoding function:

    SQL > SELECT
    2 DECODE (SIGN ((return_dte-due_dte) * 2),)
    3 '-1 ', ' 0',
    4 '1', '12', 'Null')
    5 FROM book_trans;

    DECO
    ----
    Null value
    12
    Null value
    0

    If the logic is that, if the sign is - 1, the value in the return_dte column must be 0; If it is + 1, then it has 12 and everything else is Null.

    So now, I have to conclude my function of decoding of the update statement to update the columns. However, I get the error messages.

    The logic should be:
    UPDATE book_trans SET PastDue_fees = decode (expression)

    I gave him a few different tests with the following results:

    SQL > UPDATE book_trans
    2 SET pastdue_fees = SELECT
    3 DECODE (SIGN ((return_dte-due_dte) * 2),)
    4 '-1 ', ' 0',
    5 '1', '12', 'Null')
    6 FROM book_trans.
    SET pastdue_fees = SELECT
    *
    ERROR on line 2:
    ORA-00936: lack of expression


    SQL > UPDATE book_trans
    2 SET pastdue_fees =
    3 DECODE (SIGN ((return_dte-due_dte) * 2),)
    4 '-1 ', ' 0',
    5 '1', '12', 'Null')
    6 FROM book_trans.
    OF book_trans
    *
    ERROR on line 6:
    ORA-00933: SQL not correctly completed command.

    Any help or advice would be greatly appreciated I got SQL for about six weeks and not very competent!

    Thank you!

    882300 wrote:
    Hi all

    I'm writing a query where I can update a pastdue_fees column in a table of book_trans based on a difference between the return_dte and due_dte columns.

    I use Oracle SQL. That's what I have so far for my decoding function:

    SQL > SELECT
    2 DECODE (SIGN ((return_dte-due_dte) * 2),)
    3 '-1 ', ' 0',
    4 '1', '12', 'Null')
    5 FROM book_trans;

    DECO
    ----
    Null value
    12
    Null value
    0

    If the logic is that, if the sign is - 1, the value in the return_dte column must be 0; If it is + 1, then it has 12 and everything else is Null.

    So now, I have to conclude my function of decoding of the update statement to update the columns. However, I get the error messages.

    The logic should be:
    UPDATE book_trans SET PastDue_fees = decode (expression)

    I gave him a few different tests with the following results:

    SQL > UPDATE book_trans
    2 SET pastdue_fees = SELECT
    3 DECODE (SIGN ((return_dte-due_dte) * 2),)
    4 '-1 ', ' 0',
    5 '1', '12', 'Null')
    6 FROM book_trans.
    SET pastdue_fees = SELECT
    *
    ERROR on line 2:
    ORA-00936: lack of expression

    SQL > UPDATE book_trans
    2 SET pastdue_fees =
    3 DECODE (SIGN ((return_dte-due_dte) * 2),)
    4 '-1 ', ' 0',
    5 '1', '12', 'Null')
    6 FROM book_trans.
    OF book_trans
    *
    ERROR on line 6:
    ORA-00933: SQL not correctly completed command.

    Any help or advice would be greatly appreciated I got SQL for about six weeks and not very competent!

    Thank you!

    If you really really really want to update the entire table, the syntax would be...

    UPDATE book_trans
       SET
          pastdue_fees  = DECODE(SIGN((return_dte - due_dte)*2), -1, 0, 1, 12, Null);
    

    I took out all the single quotes. If you actually have a string column and store all numbers in there so it must be reported as a NUMBER column and not a column of type character (varchar2).

    ALWAYS use the appropriate data type, it will save you a ton of headaches in the future.

    Also, since you are new to the forum, please read the FAQ to learn etiquette and what not.

    http://wikis.Sun.com/display/Forums/Forums+FAQ

  • Update from the field with consecutive number according to the number of entries

    Hello

    I need to update a field with a consecutive number according to the number of lines where the entries are made which go hand in hand. What it means:
    I have
    SYSAUSPR AREA SYSGEBIET TYP RANG
    182925 600003 4 1 PERSON
    1 600004 4 1 PERSON
    2 600004 4 1 PERSON
    3 600004 4 1 PERSON
    17 600004 4 1 PERSON
    18 600022 4 1 PERSON
    182864 600079 4 1 PERSON
    184082 600092 4 1 PERSON
    182774 600143 4 1 PERSON
    PERSON 183237 600165 4 1
    NO 7 600169 4 1
    8 600169 4 1 PEOPLE
    9 600169 4 1 PERSON
    12 600169 4 1 PEOPLE
    14 600169 4 1 PERSON
    184309 600179 4 1 PERSON
    23 600182 4 1 PERSON

    I need to change column "RANK" of 1 the number of records that have the same id in the "SYSGEBIET" column (from this example with 600) so that it looks like

    SYSAUSPR AREA SYSGEBIET TYP RANG
    182925 600003 4 1 PERSON
    1. NOBODY 600004 4 * 1 *.
    2. PERSON 600004 4 * 2 *.
    3. PERSON 600004 4 * 3 *.
    17. NO 600004 4 * 4 *.
    18. NO 600022 4 * 1 *.

    Does anyone has an idea how to solve this problem in an update statement?
    Thanks for your help
    Best regards
    Carsten
    SQL> select  *
      2    from  tbl
      3  /
    
      SYSAUSPR GEBIET  SYSGEBIET        TYP       RANG
    ---------- ------ ---------- ---------- ----------
             1 PERSON     600004          4          1
             2 PERSON     600004          4          1
             3 PERSON     600004          4          1
            17 PERSON     600004          4          1
            18 PERSON     600022          4          1
        182864 PERSON     600079          4          1
        184082 PERSON     600092          4          1
        182774 PERSON     600143          4          1
        183237 PERSON     600165          4          1
             7 PERSON     600169          4          1
             8 PERSON     600169          4          1
    
      SYSAUSPR GEBIET  SYSGEBIET        TYP       RANG
    ---------- ------ ---------- ---------- ----------
             9 PERSON     600169          4          1
            12 PERSON     600169          4          1
            14 PERSON     600169          4          1
        184309 PERSON     600179          4          1
            23 PERSON     600182          4          1
    
    16 rows selected.
    
    merge
      into tbl t
      using (
             select  sysgebiet,
                     sysauspr,
                     row_number() over(partition by sysgebiet order by sysauspr) rang
               from  tbl
               where sysgebiet like '600%'
            ) u
        on (
                u.sysgebiet = t.sysgebiet
            and
                u.sysauspr = t.sysauspr
           )
      when matched
        then update set t.rang = u.rang
    /
    
    16 rows merged.
    
    SQL> select  *
      2    from  tbl
      3  /
    
      SYSAUSPR GEBIET  SYSGEBIET        TYP       RANG
    ---------- ------ ---------- ---------- ----------
             1 PERSON     600004          4          1
             2 PERSON     600004          4          2
             3 PERSON     600004          4          3
            17 PERSON     600004          4          4
            18 PERSON     600022          4          1
        182864 PERSON     600079          4          1
        184082 PERSON     600092          4          1
        182774 PERSON     600143          4          1
        183237 PERSON     600165          4          1
             7 PERSON     600169          4          1
             8 PERSON     600169          4          2
    
      SYSAUSPR GEBIET  SYSGEBIET        TYP       RANG
    ---------- ------ ---------- ---------- ----------
             9 PERSON     600169          4          3
            12 PERSON     600169          4          4
            14 PERSON     600169          4          5
        184309 PERSON     600179          4          1
            23 PERSON     600182          4          1
    
    16 rows selected.
    
    SQL> 
    

    SY.

  • insertion of a comma in the records by using the update statement

    Hello
    I have a table with an address field LOCATIONS, and there are several files that contain Box or post office box before the street number, IE. "Box, 25 993 stone Ave", "1 194 John St box". What I would do, is add a comma between the box number and the street number for all records that start with "Box", IE 'box 25, Ave Pierre 993'. I have over 1000 addresses with a box number, an update statement would be more effective.

    I created a display to select addresses that have a number of box with 1 digit (only addresses such as 'Box 1 194 St John'). I don't know how to write a statement that inserts a comma in the 6th space to create ' box 1, 194 John St.

    Any ideas?

    You can use regular expressions

    update place set address = regexp_replace(address, 'Box ([[:digit:]]+)', 'Box \1,')
    
  • Update statement with Date field

    I'm trying to run an update statement and I want to update the date in the format:

    04/05/2010 12:31:54

    If I run this query on the double it appears correctly: select the double to_char(sysdate,'DD/MM/YYYY HH12:MI:SS PM')

    If I run this well query on my table, I get a 'not one month valid' error.


    UPDATE WR_MEASURE_VALUE SET HOST_CORRECTED_VALUE = 35,
    HOST_CORRECTED_DATE = to_char(sysdate,'DD/MM/YYYY HH12:MI:SS PM') WHERE WR_MEASURE_VALUE_OID = 474066


    what I am doing wrong and how can I get my update statement to update date correctly in the ' HH12:MI JJ/MM/AAAA: SS PM' form?

    Thank you


    Guess all I had to say was HOST_CORRECTED_DATE = SYSDATE

    Thanks anyway

    Published by: Rich75 on May 5, 2010 07:10

    If you want:

    'UPDATE WR_MEASURE_VALUE SET ' || p_FieldToInsertUpdate || '=' || v_ValueAfterFactored || ',' ||
                                      v_DateToUpdate || '= to_date(''' || to_char(sysdate, 'dd/mm/yyyy hh12:mi:ss PM') || ''', ''dd/mm/yyyy hh12:mi:ss PM'')'||
    ' WHERE WR_MEASURE_VALUE_OID= ' || v_MeasureValueOID_arr(i) ||
    ' AND ' || v_Current_25Month_Value || ' != ' || v_DisplayValue;
    

    But... smacks of dubious design if you do not know what columns you update at compile time, IMO.

  • Update statement against 1.4 million lines

    Hello

    I'm trying to run and update statement against a table with more than 1 million lines in it.

    NAME Null? Type
    ------------------------------- --------- -----
    NOT NULL NUMBER PR_ID (12.0)
    PR_PROP_CODE NOT NULL VARCHAR2 (180)
    CLOB VALUE (4000)
    SHRT_DESC VARCHAR2 (250)
    VAL_CHAR VARCHAR2 (500)
    VAL_NUM NUMBER (12.0)
    VAL_CLOB CLOB (4000)
    UNIQUE_ID NUMBER (12.0)

    The update that I'm trying to do is to take the VALUE of the column and based on some update of the parameters one of the three columns. When
    I run the sql, it's just there without error. I gave him 24 hours before killing the process.

    UPDATE PR. PR_PROP_VAL PV
    THE PV VALUE. VAL_CHAR =)
    SELECT a.value_char FROM
    (
    Select
    PPV. UNIQUE_ID,
    CASE ppv.pr_prop_code
    WHEN "BLMBRG_COUNTRY" THEN to_char (ppv.value)
    WHEN "BLMBRG_INDUSTRY" THEN to_char (ppv.value)
    WHEN "BLMBRG_TICKER" THEN to_char (ppv.value)
    WHEN "BLMBRG_TITLE" THEN to_char (ppv.value)
    WHEN "BLMBRG_UID" THEN to_char (ppv.value)
    WHEN "BUSINESSWIRE_TITLE" THEN to_char (ppv.value)
    WHEN "DJ_EUROASIA_TITLE" THEN to_char (ppv.value)
    WHEN "DJ_US_TITLE" THEN to_char (ppv.value)
    WHEN "FITCH_MRKT_SCTR" THEN to_char (ppv.value)
    WHEN "ORIGINAL_TITLE" THEN to_char (ppv.value)
    WHEN "RD_CNTRY" THEN to_char (ppv.value)
    WHEN "RD_MRKT_SCTR" THEN to_char (ppv.value)
    WHEN "REPORT_EXCEP_FLAG" THEN to_char (ppv.value)
    WHEN "REPORT_LANGUAGE" THEN to_char (ppv.value)
    WHEN "REUTERS_RIC" THEN to_char (ppv.value)
    WHEN "REUTERS_TITLE" THEN to_char (ppv.value)
    WHEN "REUTERS_TOPIC" THEN to_char (ppv.value)
    WHEN "REUTERS_USN" THEN to_char (ppv.value)
    WHEN "RSRCHDIRECT_TITLE" THEN to_char (ppv.value)
    WHEN "SUMMIT_FAX_BODY_FONT_SIZE" THEN to_char (ppv.value)
    WHEN "SUMMIT_FAX_TITLE" THEN to_char (ppv.value)
    WHEN "SUMMIT_FAX_TITLE_FONT_SIZE" THEN to_char (ppv.value)
    WHEN "SUMMIT_TOPIC" THEN to_char (ppv.value)
    WHEN "SUMNET_EMAIL_TITLE" THEN to_char (ppv.value)
    WHEN "XPEDITE_EMAIL_TITLE" THEN to_char (ppv.value)
    WHEN "XPEDITE_FAX_BODY_FONT_SIZE" THEN to_char (ppv.value)
    WHEN "XPEDITE_FAX_TITLE" THEN to_char (ppv.value)
    WHEN "XPEDITE_FAX_TITLE_FONT_SIZE" THEN to_char (ppv.value)
    WHEN "XPEDITE_TOPIC" THEN to_char (ppv.value)
    END value_char
    of pr.pr_prop_val on the map
    If ppv.pr_prop_code not in
    ('BLMBRG_BODY', 'ORIGINAL_BODY', 'REUTERS_BODY', 'SUMMIT_FAX_BODY',
    'XPEDITE_EMAIL_BODY', 'XPEDITE_FAX_BODY', 'PR_DISCLOSURE_STATEMENT', 'PR_DISCLAIMER')
    ) a
    WHERE
    a.UNIQUE_ID = pv.unique_id
    AND a.value_char is not null
    )
    /


    Thanks for any help you can provide.

    Graham

    What about this:

    UPDATE pr.pr_prop_val pv
    SET    pv.val_char = TO_CHAR(pv.value)
    WHERE  pv.pr_prop_code IN ('BLMBRG_COUNTRY', 'BLMBRG_INDUSTRY', 'BLMBRG_TICKER', 'BLMBRG_TITLE', 'BLMBRG_UID', 'BUSINESSWIRE_TITLE',
                               'DJ_EUROASIA_TITLE', 'DJ_US_TITLE', 'FITCH_MRKT_SCTR', 'ORIGINAL_TITLE', 'RD_CNTRY', 'RD_MRKT_SCTR',
                               'REPORT_EXCEP_FLAG', 'REPORT_LANGUAGE', 'REUTERS_RIC', 'REUTERS_TITLE', 'REUTERS_TOPIC', 'REUTERS_USN',
                               'RSRCHDIRECT_TITLE', 'SUMMIT_FAX_BODY_FONT_SIZE', 'SUMMIT_FAX_TITLE', 'SUMMIT_FAX_TITLE_FONT_SIZE',
                               'SUMMIT_TOPIC', 'SUMNET_EMAIL_TITLE', 'XPEDITE_EMAIL_TITLE', 'XPEDITE_FAX_BODY_FONT_SIZE', 'XPEDITE_FAX_TITLE',
                               'XPEDITE_FAX_TITLE_FONT_SIZE', 'XPEDITE_TOPIC')
    AND    pv.value IS NOT NULL
    

Maybe you are looking for

  • I have to disable M260 R7 Radeon to play Diablo 3

    Hello Why do I disable my radeon r7 m260 play with Diablo 3?When the two cards intel hd graphics and radeon work, I have a screen black but still have sound. When only the intel work the game run but run slow af and less graphic quality.Blizzard said

  • Firefox does not add the file on the file extension registration

    When I ask to save a file, the Save dialog for Firefox removes the file extension (for example, 'doc', 'pdf', "ofx") of file name, and I have to manually add it back. Earlier versions don't behave this way.

  • Select bookmarks to be sorted alphabetically

    In Internet Explorer, you can right click on the bookmark or a sub entry and choose "Sort by name" to the alphabetical entries. I think it would be great in FFIt is on 'Bookmarks Toolbar', but grayed out

  • Printer says "offline".

    My electricity went off then came back to the right, now my wireless printer says "offline".  However, the "Wi - Fi" signal is on.

  • On all the Windows 7 update Modules (X120e)

    Hi all My integrated Lenovo X120e update me program recommend to download many of these "Windows 7 update Modules", what is it?  There are like 6 that he advocates (and 12 as he is listed as compatible X120e on this page: http://www-307.ibm.com/pc/su