Page 1 of 1

Update multiple tables db2 store procedure

Posted: Mon Jan 11, 2016 8:05 pm
by john2770
Is there a way that i can update multiple tables in a db2 store procedure, if so how can i achieve this?

Re: Update multiple tables db2 store procedure

Posted: Mon Jan 11, 2016 9:05 pm
by scottgcampbell
Never tried it but it looks like it should work:

http://www.itjungle.com/fhg/fhg030806-story01.html

Using triggers instead but the article indicates that stored procedures are possible, if DB2 has standard syntax (does for almost everything) then this might help:

http://stackoverflow.com/questions/1144 ... ple-tables

Scott

Re: Update multiple tables db2 store procedure

Posted: Fri Jan 15, 2016 4:53 pm
by john2770
Is this validate to update 2 tables in a store procedure

Code: Select all

-- update the description.                                     
if          errmsg = ' ' and inDescription <> '*SAME' then     
update      prmast a                                                  
set         ( prdes1, prdes2 ) =                                      
        ( substr(inDescription,1,35), substr(inDescription,36,35))
where        a.prcucd = cucode and a.prprcd = prodCode ;              
end if ;

-- update the description for 32 table.                 
if          errmsg = ' ' and inDescription <> '*SAME' then     
update      prdpf32 b                                                  
set         ( prdes1, prdes2 ) =                                      
            ( substr(inDescription,1,35), substr(inDescription,36,35))
where        b.prcucd = cucode and b.prprcd = prodCode ;              
end if ;