can we use cl programming to update or delete physical files
Answers were Sorted based on User's Feedback
Answer / anish
Although there are no keywords to update or insert or
delete records in a CL program, we can do the same with the
help of a 'RUNSQLSTM' statement. With this command we can
runa query directly from the CL program and do an
insert/update/delete without calling an RPG program.
Plzz let me know if my understanding is corerct.
Is This Answer Correct ? | 32 Yes | 4 No |
Answer / saravan
We can clear file using CLRPFM command.
If we want delete PF we can use DLTF command.
But before delete any PF first of all we need to
delete all the LFs related in that PF.(DSPDBR=Display Data
Base Relations,we can get all LFs relating to that PF)You
must give the correct Library name for all the commands
above.
For UPDATE, DELETE & INSERT, use RUNSQL command.
Ex: RUNSQL (UPDATE LIBR/FILE SET FLD = 'XXX'
WHERE CONDITION)
Note: RMVM is to delete/remove a member from a file. But
not to delet a file completely.
Is This Answer Correct ? | 18 Yes | 2 No |
Answer / narender
No, you can access the records using the CL program but
can't perform any operation other then reading the records.
Is This Answer Correct ? | 19 Yes | 10 No |
Answer / chirag
Hi,
First you need to create a TXT source in which you need to
provie the update command.
Next in CL program you should use the command RUNSQLSTM on
this source(TXT).
So whenever you have to change another record you need to
simply change and save the TXT source.
Examply:
Data on file, PF1:
FLD1 FLD2 FLD3
000001 001 AAA BBB
000002 002 BBB CCC
000003 003 CCC DDD
000004 004 XXX ZZZ
Member1, Name: PGM1 , Type: TXT
UPDATE PF1 SET FLD3 = 'CHG' WHERE FLD1 = '004';
Member2, Name: PGM2 , Type: TXT
PGM
RUNSQLSTM SRCFILE(LIB1/SRCFILE) SRCMBR(PGM1) +
COMMIT(*NONE)
ENDPGM
Compile the PGM2 and call it.
Now Result for data on PF1
FLD1 FLD2 FLD3
000001 001 AAA BBB
000002 002 BBB CCC
000003 003 CCC DDD
000004 004 XXX CHG
Is This Answer Correct ? | 9 Yes | 3 No |
Answer / nirosh
We can clear all records from the physical file using
CLRPFM command. If we want delete PF we can use DLTF
command.But before delete any PF first of all we need to
delete all the LFs related in that PF.(DSPDBR=Display Data
Base Relations,we can get all LFs relating to that PF)You
must give the correct Library name for all the commands
above. I don't know how to update PF from the CL
programming.
Is This Answer Correct ? | 7 Yes | 2 No |
Answer / ismail
Yes, With the help of 'RUNSQLSTM' command, we can able to
update/insert/delete record in PF.
Is This Answer Correct ? | 2 Yes | 1 No |
Q:HI friends accually ihave one problem plesase let me know the alternate code of this code. Related field description of code: Add a field, CALvsPRD, "Calendar Day Starts Before/After Production Day" to the parameter set WRKORDER which accepts values 'A' or 'B' o B = Calendar Day Starts Before Production Day o A = Calendar Day Starts After Production Day o Any other value indicates the production and calendar dates are always the same. code: Automatic Execution Of *INZSR Subroutine /Z01 * retrieves WRKORDER field values. /Z01 * Calculate default Production Date and return it to caller. /Z01 * Production date defaults to system date /Z01 C Eval P@Pdate = %DATE() /Z01 * unless Calendar date starts Before PDN(production) date and /Z01 * system time is before PDN Start Time then /Z01 * PDN date is yesterday. /Z01 C If W@CALvsPRD = 'B' and /Z01 C %TIME() < %TIME (W@Strtime) /Z01 C Eval P@Pdate -= %Day(1) /Z01 * unless Calendar date starts After PDN date and /Z01 * system time is *GE PDN(production) Start Time then /Z01 * PDN date is tomorrow. /Z01 C ElseIf W@CALvsPRD = 'A' and W@Strtime > *Zero and /Z01 C %TIME() >= %TIME (W@STrtime) /Z01 C Eval P@Pdate += %Day(1) /Z01 C EndIf /Z01 C Eval *InLr = *On
How can we access Interactive job LDA in Batch Job?. and How we can access a file in interactive QTEMP lib in Batch job?.
Hi,Please give me complete code with this logic. The question is how to read the records from a file with load an array of size with error condition? (The logic is Z-Add 0 IDX *LOVAL SETLL FILE READ FILE 99 *IN9 DOWEQ *OFF IDX ANDLT 99 ADD 1 IDX MOVE FIELD ARR,IDX READ FILE 99 ENDDO)please give me complete code with explanation?
Anybody can explain the difference between SFLCLR & SFLINZ?
what is *place and *auto keyword in prtf ?plz explain
Explain mdt?
how do you use commitment control in rpg?
If my rpg program has a date field, what extra care I have to take while compiling that rpg program? If the file is keyed and I have declared the file as well as key list properly in my program. Still am getting an error message like "chain/reade operation is not allowed" what may be the case?
what is meant by record lock.how records are locked.what is the purpose of record lock.if records are locked what happens.how to find out which record is locked.
suppose if we want to update the data in cl what we will do?
explain sflclr, sflend, sfldlt, and sflcsrrrn?
Can anybody tell me in which scenario we have to use SQLRPG .(Embeded SQL)....?