On 03 Jan 2013 10:52, Stone, Joel wrote:
what is a simple easy way to clear all fields in a record? From CL
without calling an HLL pgm?
Does "without calling an HLL" program intend to imply that the CL can
only call OS features that exist? Without any compilation and without
reference to other non-OS objects that similar to a program would need
to be created or compiled; e.g. the CL must not have to first create any
objects, nor depend on other non-OS objects being pre-created, in order
to effect the desired?
Or clear all fields in all records? (but don't remove records).
For example,
Runsql 'update CUSTFILE set all cols to initial values
where RRN = 1'
If all columns allow a null value, then the following statement can
update that same selected row with all NULL values:
Runsql 'update CUSTFILE
set row=(select * from CUSTFILE where 1<>1)
where RRN = 1'
Of course removing the WHERE clause updates all rows in that manner.
If RUNSQL can be used, can a combination of that and several other CL
commands qualify under the pre-condition "without calling an HLL"? For
example a SQL request to "create table as" and other requests precede
and\or follow a RUNSQL with the UPDATE statement?
I want CUSTNAME set to spaces, CUSTZIP set to 00000, etc.
So is the desire to set each column value to the respective data-type
default rather than setting each column value to the column defaults?
Or perhaps either that or the column-default is acceptable?
Unfortunately the above doesn't work :)
Solution can use SQL or other method.
With just a cursory thought, I would probably write a SQL stored
procedure that uses dynamic SQL to generically perform whatever
statements that would be necessary to complete the task.
However, is that considered calling an SQL HLL.?
The only method I can come up with is to use CPYF *REPLACE *MAP
*DROP from another empty file, but that is hardly a clean method -
it requires another file with initial-values in the fields.
Other than MBROPT(*UPDADD), I am not sure what CPYF would be able to
do for "update" versus "insert" of data? While *MAP and *DROP are
Format Options, the *REPLACE is presumably the Member Option?
FWiW: The INZPFM can generate a "default row"; for an empty file, to
generate one such row:
INZPFM FILE(the_file) MBR(the_mbr) RECORDS(*DFT) TOTRCDS(1)
Why?
Presumably that means to suggest "You may ask... Why do I want to do
this?" rather than something like 'Why does CPYF require...'?
I use a DSPJRN outfile to join to other files, and I would like the
outfile to be initial values sometimes. Maybe it is not possible;
It is just a computer and data on the computer... so pretty much
anything is possible with regard to [re]setting the data; the only
question is if the cost to implement or perform the work is worth doing
or if there might be an entirely different approach worth pursuing.
even if there was a method, OS400 seems crude with JRN outfiles in
that they cannot be cleared???
The OUTFILE() is just a database file. The member can be cleared
just like any other database file member; the same restrictions apply to
the Output File as with any other database files or database file
members. CLRPFM and SQL DELETE are both options.
At least not thru DBU.
Not sure about via DBU... perhaps a clear attempt in the DBU is
incorrectly attempting CLRPFM while the member remains open in the job.?
As an Amazon Associate we earn from qualifying purchases.