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.
Martin’s right – always.
Here’s a number 3 for the list –
3. use OPNQRYF
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.
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
4sql. for SQL use create an alias for the specific member
5. use files
6. dltovr or drop the alias
7. rmvlfm, rmvpfm