DDS with temporary name for Physical file
115 pts.
0
Q:
DDS with temporary name for Physical file
Good day all !
On AS400 I have a CL program that creates a temporary Physical file with variable name. File name is created with "user_id + job_name + time". How can I create a logical file, specifying in DDS for logical file that my PFILE is temporary and has variable name ?
Thanks !
ASKED: Apr 9 2009  1:41 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
24510 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Hi,

I'd say you have 2 possibilites for this :-

1. Update your DDS source with the new temporary name. You could write a program to update the source before you compile the logical.

2. Use SQL to create a VIEW over the physical file. You could use RUNSQLSTM to do this.

Regards,

Martin Gilbert.
///////////////////////////////////
Martin's right - always.
Here's a number 3 for the list -
3. use OPNQRYF

Phil

//////////////////////////////////
Martin will probably improve this answer in the morning.
1. If you create a view, it will work great with subsequent SQL commands
but I don't know what other processes it will work with, or what you want to do.
A logical and a view only seem the same, they are very different things.

2. I think the source has to be altered -- which will require a program to put the view
name and the from table name into the view source before you can create it.

3. The code to change the source of the view is about the same as the code to change
the source of the logical so you may not gain anything by going with the view over the logical.

alternatively
4. In RPGLE you could build the charater string that represents the view and do the stuff to run a dynamic SQL
command - prepare a statement and run it...

5. And then user_id + job_name + time seems too long - our object names can only be 10 char's long


Here is an easy alternative .. although we haven't talked about how you will use it - so this might be better or useless - physical files and logical files can have more than one member just as source does.

1. create the generic pf and lf - either in your CL or they could be permanent objects

2. add a member to the generic PF addpfm -- the member name can be your variable (10 char max)

3. add a member to the generic LF addlfm
you fill in the part of addlfm that identifies the physical file and the member name

4. ovrdbf generic to specific members
or
4sql. for SQL use create an alias for the specific member
5. use files
6. dltovr or drop the alias
7. rmvlfm, rmvpfm

Phil
Last Answered: Apr 9 2009  9:32 PM GMT by Philpl1jb   24510 pts.
Latest Contributors: Gilly400   23625 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Lenny2113   115 pts.  |   Apr 9 2009  8:21PM GMT

Martin, Phil :

Thank you for your help. My background is mainframe where JCL is used instead of CL…
I am not sure how this can be done. Please pardon my ignorance.

If in my CL program I do RUNSQLSTM command should the source for CREATE VIEW be in a specific file type?

This is a code from my CL program which defines physical file called &WKPF:

CRTPF FILE(QS36F/&WKPF) SRCFILE(LENNYTEST/QDDSSRC) +
SRCMBR(G4TENSWK) OPTION(*NOSRC *NOLIST) +
LVLCHK(*NO)
RUNSQLSTM SRCFILE(LENNYTEST/QDDSSRC) SRCMBR(CRTQRY1)
/* CRTLF FILE(QS36F/&WKLF) SRCFILE(LENNYTEST/QDDSSRC) +
SRCMBR(G4TENSLF) */
/* */
/* */
In CREATE VIEW statement can I code symbolic parameters which are given value in my CL program?

CREATE VIEW &WKLF — (parameter is supplied from CL)
AS SELECT COMPNY,
PROJNO,
BLDNUM,
UNTNUM
FROM &WKPF ;

This is my logical file that I need to replace by “create view”
A R G4TENSR PFILE(G4TENSWK)
A*
A K COMPNY
A K PROJNO
A K BLDNUM
A K UNTNUM

Thank you !
Lenny

 
0