Updating multiple table in one command passing a value through a variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cimetta
    New Member
    • Sep 2007
    • 3

    Updating multiple table in one command passing a value through a variables

    Does anyone knows how could i do make haapen this in oracle 9i

    please help!

    *************** *************** ***********

    var a
    var b

    var a = ' 4844'
    var b = ' 4851'

    update sevt
    set resid = 'a'
    where resid = 'b'

    and

    update evdub_ex
    set resid = ' 4844'
    where resid = ' 4851'
  • chella
    New Member
    • Mar 2007
    • 51

    #2
    Hi,

    Can you explain more on your problem.

    Regards,
    Chella

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Please post your question bit more clearly.

      Comment

      • cimetta
        New Member
        • Sep 2007
        • 3

        #4
        Sorry everyone

        I should have been a bit more precise:

        what I need to do is update few tables at the same time and all passing the same value so I would like to know if with oracle 9i
        it is possible to assign a value to a variable then pass this value to the fileds when running my update statement

        so:

        presuming that this will work I would like to do something like that:

        variable a varchar(8);
        variable b varchar(8);
        exec :a := ' 4844';
        exec :b := ' 4851';

        update sevt
        set resid = 'a'
        where resid = 'b';

        update evdub_ex
        set resid = 'a'
        where resid = 'b';

        update prefres
        set resid = 'a'
        where resid = 'b';


        so that instead of updating the value against any set update i can do it once against the variables

        hope this make sense to you!

        Thanks For your responce

        Cimetta

        Comment

        • Saii
          Recognized Expert New Member
          • Apr 2007
          • 145

          #5
          Is this what you intend to do?

          declare
          a varchar2(8) := '4844';
          b varchar2(8) := '4851';

          begin
          update sevt
          set resid = a
          where resid = b;

          update evdub_ex
          set resid = a
          where resid = b;

          update prefres
          set resid = a
          where resid =b;
          end;

          Comment

          • cimetta
            New Member
            • Sep 2007
            • 3

            #6
            Saii

            bless you!!!!

            it is working fine

            thanks you so much for your help!

            Cimetta

            Comment

            Working...