Update multiple tables db2 store procedure

The place for general PHP questions and hints for PHP on IBM i
Post Reply
john2770
Posts: 7
Joined: Wed Oct 07, 2015 5:10 pm

Update multiple tables db2 store procedure

Post by john2770 » Mon Jan 11, 2016 8:05 pm

Is there a way that i can update multiple tables in a db2 store procedure, if so how can i achieve this?

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: Update multiple tables db2 store procedure

Post by scottgcampbell » Mon Jan 11, 2016 9:05 pm

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

john2770
Posts: 7
Joined: Wed Oct 07, 2015 5:10 pm

Re: Update multiple tables db2 store procedure

Post by john2770 » Fri Jan 15, 2016 4:53 pm

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 ; 

Post Reply