View previous topic :: View next topic
|
Author |
Message |
alamak
New User
Joined: 06 May 2009 Posts: 5 Location: india
|
|
|
|
Hi,
I have the following requirement:
1. Search all the members of a given pds to extract sql statements from the members and write just the sql statements to a new file.
step 1 : open the pds.
step 2: search each memeber in pds.
step 3: for each memeber search for 'exec and end-exec' and copy the code between these two statement to stem.
there can be multiple sql execs in a single module.
Can someone please help me on this...
Thanks |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
alamak wrote: |
Can someone please help me on this...
|
Maybe. Show us what you've done so far, what you need help on, where you're stuck. Doesn't sounds like anything very difficult, but you obviously know more about what you want to do than us. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
why don't you just access the DBRM's? |
|
Back to top |
|
|
alamak
New User
Joined: 06 May 2009 Posts: 5 Location: india
|
|
|
|
I havent stated as of yet... but off the three steps - the first two are fairly simple.
in reg to the step 3., consider ofr e.g.
code line 1
code line 2
exec sql
select a
from b
where c=d
order by crt_ts desc
end-exec
code line 3
code line 4
my output should contain..only the following:
exec sql
select a
from b
where c=d
order by crt_ts desc
end-exec
also., if there are multiple exec statements in a single memebr., I need to get all those statments.
so., how to keep the mentioned part of code into stem. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
stem_name.number = variable |
|
Back to top |
|
|
alamak
New User
Joined: 06 May 2009 Posts: 5 Location: india
|
|
|
|
Iam sorry - but can you please be a bit elobarate? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
There is a sticky at the top of the CLIST/REXX forum which links to the manuals. These will explain stem variables better than I will. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
alamak,
what exactly will this 'extracted sql' be used for?
Is this just an exercise in REXX?
or is the output file (containing the SQL) going to be analyized for some purpose? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
also,
instead of having multiple stems,
your logic could be to write the stem each time you have found the END-EXEC. |
|
Back to top |
|
|
alamak
New User
Joined: 06 May 2009 Posts: 5 Location: india
|
|
|
|
the output will be used for assesing sqls.
in regard to the manuals., i have cheked them but could not get what iam exactly looking for.
Each time i encounter a EXEC SQL., i can capture this line to stem., but next part is to capture everything in the module till i encounter an en-exec statment. once i encouter an end-exec i can write the whole info into stem.
And further the code should then look for thenext exec statment in the same module. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Well for me it is just common sense.
Having read the data/program/module/whatever into a stem you process the stem using a flag set to either 1 or 0 to determine if the record is written or not.
Code: |
Read program into Stem.
DO aa = 1 to Stem.0
If POS('EXEC SQL',Stem.aa) > 0
then flagwrt = 1
If flagwrt = 1
then QUEUE Stem.aa
If POS('END-EXEC',Stem.aa) > 0
then flagwrt = 0
END
Write Queued records to output dataset or whatever
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
the output will be used for assesing(sic) sqls. |
That is the purpose of the output of EXPLAIN: Plan table.
If the bind option is EXPLAIN(YES) you have all the SQL,
in the plan table.
So instead of learning REXX to generate something that will not help you in your ultimate goal,
why don't you learn a little DB2 and dump the plan tables for your modules? |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
It all depends of what the "assessment" is
If the sources have been bound :
even without explain(yes) the statements are in some form in sysibm.syspackstmt.
dependencies can be found in SYSIBM.SYSPACKDEP
If you do have explain-info
A lot of parsed material is in several tables :
DSN_PREDICATE_TABLE
DSN_SORTKEY_TABLE
and even a completely to XML parsed statement can be found in
DSN_QUERY_TABLE |
|
Back to top |
|
|
alamak
New User
Joined: 06 May 2009 Posts: 5 Location: india
|
|
|
|
Well.. thanks for the replies...
getting plan_table alone wont suffice my requirement. the requirement involves column definitions, key words and etc.., i was able to get a solution using rexx. which basically strips jsut the sql code into a new file.
appreciate all your inputs.. |
|
Back to top |
|
|
|