can we use cl programming to update or delete physical files

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can I touch the array during treatments?

962


Explain mdt?

890


what is an online rpg?

1002


thanks mr.Harshad R Suryawaunshi,i'm new to as400 i think you are telling in rpgile i know only rpg400 if possible can you tell in rpg400

2105


Interviewer asked me write down DDS for load all subfile .can anybody write dds

1403


How to call one program from another program in RPG? please help me with the code

1502


What is file identifier where we can use?

872


what is the necessary keyword needed to scroll subfile records?

933


1. What is bound-by-call and bound-by-reference? 2. Where and why is *Nomain used? 3. What are the difficulties faced by programmers when using service programs? 4. Explain the different ways of parsing and compiling XML in iSeries.

5977


write an RPG program to calculate the marks of 5 students (A,B, C, D, E)in 3 different subjects (eng, math, sci) an display on the screen

1075


what is data area and how it is used in rpg program ?

1052


what is the procedure and explain about real time scenario.

1722


what do you mean by an input subfile, what are the keywords required?

1044


do you use message subfiles? What are the necessary keywords required coding a message subfile?

922


When it is desirable to describe files Internally?

1414