Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Multiple update statements in a stored procedure

$
0
0
Hi,

I am still learning sql so take it easy on me :)

I have several update statements that I have to run on a fairly regular basis and I would like to be able to make them all one action and based on my research a stored procedure seems like a good way to do it. So here is my current code that does not work the first update statement work fine but it doesn't like the syntax where I added the second update statement. This is on an IBM i in case that matters.

CREATE PROCEDURE KELLYP/ACTIVATEPN
(IN BRANCH NUM(2,0))
MODIFIES SQL DATA
UPDATE KELLYP/insmft A1 SET A1.SBNSI = 5 WHERE
EXISTS (SELECT 'PN' FROM kellyp/nsi A2 WHERE A1.SUNFMT = A2.PN AND
A1.SFRAN = 'NT' and a1.SBRAN = BRANCH and A2.BR = BRANCH)

UPDATE KELLYP/INSMFT A3 SET A3.SMU1 = 200 WHERE EXISTS (SELECT 'PN'
FROM KELLYP/NSI A4 WHERE A3.SUNFMT = A4.PN AND A3.SFRAN = 'NT' AND A
3.SBRAN = BRANCH AND A4.BR = BRANCH)

Viewing all articles
Browse latest Browse all 13329

Trending Articles