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,')

Tags: Database

Similar Questions

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

  • the update statement modidy

    Hi all

    I have here is the update statement in my code

    UPDATE equip_stg stg

    SET stg.err = 'WRC '.

    WHERE DOES NOT EXIST (SELECT *)

    FROM (SELECT stg.*

    Of equip_stg stg.

    REASON_SETUP sea

    WHERE stg.equipment_fk = mer.equipment_pk

    AND stg.downtime_reason_code = mer.reason_code

    AND ((stg.status = 3 AND sea. REASON_TYPE = 1)

    OR (stg.status = 2 AND sea. REASON_TYPE = 3)

    OR (stg.status = 1 AND sea. REASON_TYPE = 4))

    ERS stg.downtime_reason_code AND IS NOT NULL)

    WHERE ers.equipment_fk = stg.equipment_fk

    AND ers.downtime_reason_code = stg.downtime_reason_code

    )

    AND stg.status IN (3,2,1)

    AND stg.downtime_reason_code IS NOT NULL;

    The statement above sets updated the column equip_stg in WRC if err for corresponding material and reason, there is no line in the REASON_SETUP table.

    I want to change the code above so that the validation above is first done with REASON_SETUP according to equipment and column of type of reason. Is there is no line for this type of material and the reason in this table, then he must hit lookup table.  Example, I have data from equipment EQP1, status = 3, then it should check if REASON_SETUP has everything save for EQP1 equipment and the reasoning of type 1. If she made the next record should be validated on the table otherwise come file should be validated against the lookup table. For the table of choice also I have same join conditions

    STG.equipment_fk = lookup.equipment_pk

    AND stg.downtime_reason_code = lookup.reason_code

    Thanks in advance.

    Kind regards

    Amrit

    Hello

    I think I see.  All lines for each (equipment, reason_type) will be removed completely on a table or another. reason_setup if possible and looking as if this combination never occurs in reason_type.  Another way to say it is that you want only (equipment, reason_type) groups of the best tablle, where reason_type is better than search.  Exactly what made a Request Top - N .  Here's a way to do it:

    UPDATE equip_stg

    SET err_code = "WRC".

    WHERE (equipment, downtime_reason_code) NOT IN

    (

    WITH union_data AS

    (

    SELECT 'A' preference AS, reason_code, reason_type, equipment

    OF reason_setup

    UNION ALL

    SELECT equipment, reason_type, reason_code, 'B' AS preferences

    SEARCH

    )

    got_r_num AS

    (

    SELECT equipment, reason_type, reason_code

    DENSE_RANK () (PARTITION BY MATERIAL, reason_type

    ORDER OF preference

    ) AS r_num

    Of union_data

    )

    SELECT equipment

    DECODE (reason_type

    1, 3

    3, 2

    )

    reason_code

    OF got_r_num

    WHERE r_num = 1

    )

    ;

    To see how this works, reconstruction of the NOT IN subquery, step by step.  First run just union_data as a stand-alone application.  When you understand what it does, run got_r_num and when you see what he's doing, run the set NOT IN subquery.

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

  • How to use the user defined function in the Update statement

    Hi all

    I wrote under the update statement to update the column based on the return value of function. but it does not work. Could someone help me on this. This function returns a single value for each project.

    Thanks in advance.

    UPDATE dg2. OD_PROJ_LOOKUP_TEMP o
    SET Months_In_Stage_Cnt = Months_In_Stage_Cnt_ret (o.project_id) select the double;


    Thank you
    Deb

    PLS-00231: function 'MONTHS_IN_STAGE_CNT_RET' cannot be used in SQL

    -What is the function that is declared private in a package? If Yes, then it must be public, otherwise the SQL engine cannot be used.

    Published by: Dom Brooks on November 18, 2011 09:43

  • 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

  • need help with the Update statement

    Hello
    I received a question in a course and I tried my best to respond, and now my brain is giving. I would really appreciate help with the update statement. I don't mind if you do not validate a solution, a little nudge in the right direction would be really useful. I'll post that I got.

    THE QUESTION
    / * For these agents disabled on more than seven missions, change their date of deactivation of the first date of deactivation of all the agents that have been activated in the same year as the agent that you update currently.
    */

    I have it divided into parts, here is my select statement to agents disabled on more than 7 missions, which produces the deactivation_dates in the agents table that I want to update...
    SELECT
    s.deactivation_date
    FROM
    (
    SELECT
    a.deactivation_date,
    count(m.mission_id) as nomissions
    FROM
    agents a
    INNER JOIN
    missions_agents m
    on
    a.agent_id=m.agent_id
    GROUP BY
    a.deactivation_date
    ) s
    WHERE
    s.nomissions>7 AND s.deactivation_date IS NOT NULL
    .. .and the code for the first date of deactivation for each year of activation agent
    select 
    a2.deactivation_date
    from
    agents a2
    where a2.deactivation_date= 
    (
    select min(a.deactivation_date)
    from 
    agents a
    where to_number(to_char(a.activation_date,'YYYY'))=to_number(to_char(a2.activation_date,'YYYY'))
    )
    ..... I am not real to marry these two statements together in the Update statement. I can't extract each date of deactivation produced in the first select statement and their match against the first date of deactivation in the year they have been activated for the second select statement.

    Any help greatly appreciated... :))

    I began to wonder how things would :)

    user8695469 wrote:
    First of all why he chooses the date the earliest of all agents

    UPDATE  AGENTS_COPY AC /* (1) */
    SET     DEACTIVATION_DATE = (
    SELECT  MIN(AGS.DEACTIVATION_DATE)
    FROM    AGENTS_COPY  AGS
    ,       AGENTS_COPY AC /* (2) */
    WHERE   TRUNC(AGS.ACTIVATION_DATE,'YEAR') = TRUNC(AC.ACTIVATION_DATE,'YEAR') /* (3) */
    )
    

    He recovers as soon as the subquery has not been correctly set in the SET clause. It seems you are trying to update a correlated, but we are still having a conceptual shift. I have added a few comments to your code above and below will explain.

    (1): when you do a correlated update it is useful to the table alias that you did right here.

    (2): this table statement is not necessary and is the reason why the FIRST deactivation date is selected. The alias that you use (3) refers to THIS table, not the one defined in the update statement. Remove the line indicated by (2) in the FROM clause and a correlated update will happen.

    and secondly why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)

    user8695469 wrote: then why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)

    
    WHERE EXISTS
    (
    SELECT
    a.agent_id,
    count(m.mission_id)
    FROM
    agents a
    /* INNER JOIN AC ON AC.AGENT_ID = A.AGENT_ID */
    INNER JOIN
    missions_agents m
    ON
    a.agent_id=m.agent_id
    GROUP BY
    a.agent_id,
    a.deactivation_date
    HAVING
    count(m.mission_id)>7 AND a.deactivation_date IS NOT NULL
    )
    

    Once again this problem is similar to the question above that a correlation update doesn't work. Test existence of lines in an EXISTS subquery. Since your subquery is not related to the table that you are trying to update, it will be always return a line and, therefore, it returns true for EACH LINE in the AGENTS table. To limit the game to only agents > 7 missions results, you need to add a join condition that references the table in your update statement. I added one above (with comments) as a sample.

    I recommend you look over all material that you have associated with correlated subqueries, including documents that I posted above. This seems to be what you're having the problem more with. If you need me to explain the concept of correlated queries any better please let me know.

    Thank you!

  • The UPDATE statement: view Multi level Inline.

    This is the test case.
    create table source(old_val integer, new_val integer)
    / 
    create table target(val integer)
    / 
    insert into target values(1)
    / 
    insert into target values(2)
    / 
    insert into target values(3)
    / 
    insert into source values(1,4)
    / 
    insert into source values(1,5)
    / 
    insert into source values(2,6)
    / 
    insert into source values(3,7)
    / 
    insert into source values(3,8)
    / 
    commit
    / 
    Now I want to update target.val with source.val and the corresponding condition is source.old_val = target.val

    But source.old_val can have multiple values for a given target.val. You can see in the example. I would like to order by ROWID of source and choose the first record.

    So I wrote an UPDATE.
    SQL> update target t
      2     set (val) = (select new_val
      3               from (select new_val, row_number() over(order by rowid) rno
      4                       from source s
      5                      where s.old_val = t.val)
      6              where rno = 1)
      7   where exists(select null
      8             from source s
      9            where t.val = s.old_val)
     10  / 
     
    3 rows updated.
    and that's what I got.
    SQL> select * from target
      2  / 
     
           VAL
    ----------
             4
             4
             4
     
    SQL> select * from source
      2  / 
     
       OLD_VAL    NEW_VAL
    ---------- ----------
             1          4
             1          5
             2          6
             3          7
             3          8
    I expected the updated as 4,6,7 or 5,6,8 value but don't know why its 4,4,4.

    Just try to understand how this update is underway. Not sure if I am missing something basic.

    NOTE: I'm interested in the behavior of this update statement and not another method to solve the problem.

    Thank you

    Knani.

    Well, I think that it is related to the #374632.1 bug, already discussed in [this thread | http://forums.oracle.com/forums/thread.jspa?messageID=2134151]
    In short, your case should return the error I, ORA - 904.

    Nicolas.

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

  • 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

  • How to upgrade several records or table using single update statement.

    Hello friends,

    I'm going to abc and xyz table.

    ABC: columns
    Ein, equipementid
    1-99999
    2 99999
    3 99999

    total records 1000

    columns of XYZ:
    Ein, equipementid
    1 1234
    2 3456
    2 4567
    4 4567

    total records 10000000

    I want equipmentid update table abc with equipmentid table xyz for ein game (like abc.ein = xyz.ein) and then had to delete record from table xyz corresponds to ein and equipentid who has updated the record in abc.

    Note: If you see xyz for ein table 2 we have two different equipmentid, we update with any value and only the record of xyz must be deleted once updated.

    A single declaration for the update and only statement needing to remove.

    Appreciate your help.



    Thank you / kumar

    Published by: kumar73 on August 2, 2012 13:02

    Maybe

    merge into abc
    using (select ein,max(equipmentid) equipmentid
             from xyz
            group by ein
          ) x
       on abc.ein = x.ein
     when matched
     then update
             set abc.equipmentid = x.equipmentid
    
    delete from xyz
     where exists(select null
                    from abc
                   where ein = xyz.ein
                     and equipmentid = xyz.equipmentid
                 )
    

    Concerning

    Etbin

  • Solution probably really Simple (where in the Update statement)

    Right,

    I have a table. In this table, there are 5 fields for the sake of arguments:

    COLUMN_ONE COLUMN_THREE COLUMN_FOUR COLUMN_FIVE COLUMN_TWO

    On this table there will be duplicate records, but only the column 1, column 2 and 3 on these "duplicate" files will be the same, column 4 will be different (column 4 is not a unique identifier, but if there are duplicate records, it will be different at least 2 records). Column 5 is not yet filled, all null.

    I need a way to update column 5 of these duplicate records. However, let me update on one of the folders and the criteria for this will be where column_4 = "Hello".

    So far I came with an update statement similar to the following, but I don't know where with her:

    UPDATE DANS_TABLE
    SET COLUMN_five = "DUPLICATE".
    WHERE EXISTS (SELECT column_one | column_two | column_three, COUNT (*))
    OF DANS_TABLE
    GROUP BY column_one | column_two | column_three
    SEEN (COUNT (*) > 1)) and column_four = 'Hello ';

    For any help, thank you very much! Much appreciated,

    Dan

    This is the query that updates that one line duplicated to column_five. I hope this helps...

    UPDATE DANS_TABLE x 1
    SET COLUMN_five = "DUPLICATE".
    WHERE THERE ARE
    (
    Select r_id of
    (select max (rowid) r_id, column_one | column_two | column_three)
    of DANS_TABLE t1 where exists
    (
    Select str of
    (
    SELECT column_one | column_two | column_three str, COUNT (*)
    OF DANS_TABLE
    GROUP BY column_one | column_two | column_three
    SEEN (COUNT (*) > 1)
    ) t2 where t2.str = t1.column_one | T1.column_two | T1.column_three
    ) column_one group | column_two | column_three
    ) x 2 where x 1 .rowid = 2 .r_id x
    ) and column_four = 'Hello ';

  • CASE IN THE UPDATE STATEMENT

    update capitation
    set pcp_cap = (select case when year in ('2009','2010') then 10 else 20 from cap_rate;
    is that correct?

    Hello

    Whenever you have any questions, post a small example of data (in this case, CREATE TABLE and INSERT all tables for instructions as it exists before the UPDATE), and the results that you want from these data (the content of capitation after the UPDATE). Explain how you get these results from these data.
    It never hurts to say what version of Oracle you are using.

    788729 wrote:

    update capitation
    set pcp_cap = (select case when year in ('2009','2010') then 10 else 20 from cap_rate;
    

    is that correct?

    You are in a better position than anyone else to say.
    What happens when you run?

    If you get errors, check the balanced parentheses and a corresponding END to the CASE. Format your code so that you can see these things easily.
    Are you sure that the subquery never returns more than one row?
    You want to UPDATE all rows in capitation?

  • Behavior of the UPDATE statement

    Hello

    I have a problem, updates of anonymous block according to all the rows in a table, I was hoping that the where the statement would force the latter to limit the update...

    < pre >

    DECLARE

    BEGIN

    C1 IN
    (SELECT a.deptno
    b.empno
    b.job
    DEPARTMENT one
    b emp
    WHERE a.deptno = b.deptno)

    LOOP

    UPDATE emp SET work = 'GARDENER' WHERE c1.empno = 1000 AND c1.deptno = 30;
    COMMIT;

    END LOOP;

    END;

    < / pre >

    and yet when I run it by himself, he not exacltly I expect to...

    UPDATE emp SET work = 'GARDENER' WHERE empno = 1000 AND deptno = 30;
    COMMIT;


    Anyone would be able to explain to me what is happening?

    Thanks for any help
    Ben

    Assuming that there is a line in the C1 cursor where empno = 1000 and deptno = 30, then the line

      UPDATE emp SET job = 'GARDENER' WHERE c1.empno = 1000 AND c1.deptno = 30;
    

    updates all rows in the EMP since there is no WHERE clause, which applies to the EMP table, just for the cursor C1.

    What is it, exactly, that you are trying to accomplish? I guess you are trying to update the emp table based on the lines that you get the cursor, but the exact requirements don't are not obvious to me from the code you posted.

    In addition, you do want to commit in a loop. Who can very easily lead to errors ORA-01555 (among others)

    Justin

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

Maybe you are looking for

  • How to increase the capacity of my iTunes iCloud?

    I have a big disco in my iTunes (probably 300 GB.) I recently paid $24.99 for iCloud music, but it's not big enough for my entire library. I also signed up for the iCloud 1 TB, thinking I could develop my ability to iCloud iTunes on that, but I can't

  • Satellite L500 - second module of memory not recognized

    Have installed 2 GB Offtek extra memory in 2nd slot of memory, but it is not recognized by the system--still show only 2 GB installed memory. What is the problem?

  • Get the current name of the Run Script

    Hello I'm looking for the name of the current script that runs in DIadem. So I would like to call a script, and then everything is running I would record the name of the script (file name on disk) a text box on a report that I am generating. I know h

  • As Facebook blocked me...

    Facebook as blocked, me, saying I sent asking people I have not know.i havn't sent a request more than one week, which was a person I know. Facebook worked very well before lunch, but when I went back to him I was denied, and I don't know why! I have

  • Pavillion 17z-e000: win 7 drivers required for HP pavilions Z - e000

    {HELP}: I'm looking for drivers for the UNKNOWN DEVICE for HP Pavillion 17z-e000. Win 7 Professional 64-bit. Here are the details: USB controller Location: PCI Bus 0, device 16, function 0 PCI\VEN_1022 & DEV_7814 & SUBSYS_213C103 & REV_01 PCI\VEN_102