Updating Multile rows in a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DhanyaS
    New Member
    • Jan 2008
    • 1

    Updating Multile rows in a table

    Hello All,
    I have got a table like below :-

    Name (varchar2) Code(varchar2) Details
    ABC 123_o kkkk
    PQR 456_U RRR

    I just put only two rows where as there will be 1000 rows.

    I want the table to be like below after update

    Name (varchar2) Code(varchar2) Details
    100_Name 100 kkkk
    101_Name 101 RRR

    Please note that i just want to update the name which is based on the code value and code value should be in the ascending order, where as the code and Name orginal field values wont have any link with the the values with which it is going to be get updated.


    Please send me the update query for the above issue.

    Thanking you in advance.

    Regards,
    Dhanya
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try to do the same using a cursor inside an anonymous block or use a procedure.

    Comment

    • cvraghavan1979
      New Member
      • Jan 2008
      • 28

      #3
      Originally posted by debasisdas
      Try to do the same using a cursor inside an anonymous block or use a procedure.
      Hi,

      can u send the exact form of original data and the data form u want to convert with. i couldn't get the clear idea of the modification u require.
      regards,
      vijay

      Comment

      • subashsavji
        New Member
        • Jan 2008
        • 93

        #4
        [code=oracle]

        create or replace procedure proc11(v_ename1 in varchar2,v_enam e2 in varchar2) is
        CURSOR CUR2 is SELECT empno from emp where ename=v_ename1 order by empno;
        begin
        for i in CUR2 loop
        update emp
        set ename=v_ename2
        where empno=i.empno;
        end loop;
        end;
        /

        EXECUTE PROC11('KING',' EMPAROR');

        [/code]



        NOW USE THIS PROCEDURE IN ANY PROGRAMME WHERE WE CAN PASS ONE BY ONE VALUES IN LOOP STATEMENT.
        Last edited by amitpatel66; Jan 30 '08, 01:25 PM. Reason: code tags

        Comment

        Working...