IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Stored Procedure perform code multiple times - HOW????


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prgaj1

New User


Joined: 13 Jul 2007
Posts: 18
Location: Pennsylvania

PostPosted: Fri Apr 23, 2010 5:16 pm
Reply with quote

Hi there
We doing an audit trail and for each field I need to call a Stored procedure (SP2) which insert a record to the audit table. I want to do a sort of perform in my current Stored Procedure (SP1) but is not sure how..

Set field1 to abc...
Set field2 to abc...

Call SP2

Set field1 to cde...
Set field2 to cde...

Call SP2
.
Set......
I need to call SP2 multiple times and was wondering if I could create a LOOP or something that will iterate the same call... Is it possible? where do I find information on that...
Thanks in Advance
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Apr 23, 2010 7:06 pm
Reply with quote

you can multi-post all you want,
but maybe you could just bother to read the manual?

DB2 for z/OS Stored Procedures - IBM Redbook

DB2 vsn 9 for z/OS Stored Procedures - IBM Redbook

Stored Procedures, Triggers, UDF for ISeries - IBM Redbook
Back to top
View user's profile Send private message
prgaj1

New User


Joined: 13 Jul 2007
Posts: 18
Location: Pennsylvania

PostPosted: Fri Apr 23, 2010 8:33 pm
Reply with quote

If I could find it in a manual I would not have asked.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Fri Apr 23, 2010 9:12 pm
Reply with quote

Prgaj1,

Quote:
I need to call SP2 multiple times and was wondering if I could create a LOOP or something that will iterate the same call... Is it possible?


Did you try ? Did you get any errors ?

Sushanth
Back to top
View user's profile Send private message
prgaj1

New User


Joined: 13 Jul 2007
Posts: 18
Location: Pennsylvania

PostPosted: Mon Sep 27, 2010 2:10 pm
Reply with quote

Sushanth I got a work around could not find anything in the manual like I assume Dick Brenholtz could not either that is why he was so unhelpful and rude..
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Sep 27, 2010 2:17 pm
Reply with quote

prgaj1 wrote:
why he was so unhelpful and rude.


is just another way of crying like a little baby, because I did not give you code to accomplish your task.

Since you did not bother to explain
from which programming language you were invoking the SP,
how do you expect anyone to provide you code
or actually do your work for you.

besides, it is sort of a non-question.
what do you mean invoke multiple times.
you want to loop the following:
populate parms
call

the population of the parms is the key to the loop.
you explained nothing about the source of the data/values for the parms.
your problem lies more in the area not being able to explain your requirement,
and less about a members 'social graces'.
Back to top
View user's profile Send private message
prgaj1

New User


Joined: 13 Jul 2007
Posts: 18
Location: Pennsylvania

PostPosted: Mon Sep 27, 2010 2:57 pm
Reply with quote

If you were helpful you would have ask if you did not understand what was asked...
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Mon Sep 27, 2010 3:02 pm
Reply with quote

if instead of fussing You had posted some meaningful info
You would have got better replies

read and meditate on
How To Ask Questions The Smart Way
catb.org/~esr/faqs/smart-questions.html
to make the most out of the questions You ask
Back to top
View user's profile Send private message
prgaj1

New User


Joined: 13 Jul 2007
Posts: 18
Location: Pennsylvania

PostPosted: Mon Sep 27, 2010 3:10 pm
Reply with quote

Thanks Enrico I will bookmark and next time refer to it to make sure I ask the question correct. I still feel it was not necessary for the Eric to be rude about it... Surely one do not ask a question before checking in manuals and with collegues... next time I will follow your advise on how to ask...
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Mon Sep 27, 2010 3:15 pm
Reply with quote

Quote:
Surely one do not ask a question before checking in manuals and with collegues...


if You look carefully at the forums the vast majority of the questions asked
would not have been asked if the TS had looked at the manuals

so statistics and forum experience hint that the first suggestion to give is RTFM icon_biggrin.gif
Back to top
View user's profile Send private message
mallik4u

New User


Joined: 17 Sep 2008
Posts: 75
Location: bangalore

PostPosted: Mon Sep 27, 2010 3:19 pm
Reply with quote

Hi Prga1,

I am assuming that you have coded your stored procedures using DB2-SQL.
SQL has WHILE keyword for doing looping in DB2.

WHILE <condition> DO
<your SQL statements...>
END-WHILE
Back to top
View user's profile Send private message
prgaj1

New User


Joined: 13 Jul 2007
Posts: 18
Location: Pennsylvania

PostPosted: Mon Sep 27, 2010 3:24 pm
Reply with quote

Thank you I see where you come from. I do not post a lot as most of the time I find what I need in previous posts, so that should indicate to me that the vast majority just ask before check for themselves. I have learned a lot about syncsort by just reading previous post without any before hand knowledge, so your statement is true. icon_redface.gif
Back to top
View user's profile Send private message
prgaj1

New User


Joined: 13 Jul 2007
Posts: 18
Location: Pennsylvania

PostPosted: Mon Sep 27, 2010 4:21 pm
Reply with quote

Hi Mallik; that you very much I it was exactly what I used. We converting some COBOL programs to SQL SP's and I just did not know how on earth to do the perform. The SQL WHILE statement is actually convertion for a COBOL PERFORM UNTIL statement but I got it work for the normally COBOL PERFORM statement with a bit of IF logic inside the DO WHILE loop... I tried the "LOOP" statement but not sure I quite understand it because I needed to perform my routine for different senarios at different times, it was quite fun testing it but it work and is implemented already.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts purge jobs with return code 0 and ret... JCL & VSAM 4
No new posts Excuting store procedure via JCL batch JCL & VSAM 1
No new posts Executing DB2 SQL store procedure via... DB2 0
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts Repeat n times by substuting SEQNUM i... DFSORT/ICETOOL 2
Search our Forums:

Back to Top