Update multiple tables db2 store procedure

The place for general PHP questions and hints for PHP on IBM i

Update multiple tables db2 store procedure

Postby john2770 on 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?
john2770
 
Posts: 7
Joined: Wed Oct 07, 2015 5:10 pm

Re: Update multiple tables db2 store procedure

Postby scottgcampbell on 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/11444923/stored-procedure-to-update-multiple-tables

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

Re: Update multiple tables db2 store procedure

Postby john2770 on 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 ;
john2770
 
Posts: 7
Joined: Wed Oct 07, 2015 5:10 pm


Return to PHP Questions / Hints

Who is online

Users browsing this forum: No registered users and 1 guest

cron