Thanks gagan for your answer,i'm new to as400,i don't know
embedded sql in rpg.can you send me the coding for the below
mentioned question in embedded sql rpg.
how to retrieve particular field records from a physical
file,say i have a physical file called 'employee' in it i
have to retrieve the records of a field 'admin' present in
pf 'employee' using rpg,but i should not use logical file
or openquery file.

Answers were Sorted based on User's Feedback



Thanks gagan for your answer,i'm new to as400,i don't know embedded sql in rpg.can you s..

Answer / harshad r suryawaunshi

1. Declare cursor first - It will select all the record
available in the filed 'ADMIN'

c/exec sql
c+ declare cr1 cursor for
c+ select ADMIN from EMPLOYEE
c/end-exec

2. Open the cursor - its like seting the pointer on the
first record

c/exec sql
c+ open cr1
c/end-exec

3. Fetch the cursor - its like reading the records in the
cursor. NAME is the field defined in the program which
attributs are same as per field ADMIN.

c/exec sql
c+ fetch cr1 into :name
c/end-exec

This code u can execute in Do loop to read all the records.
The complete coding would look like this

c/exec sql
c+ fetch cr1 into :name
c/end-exec

C dow sqlcod <>100
C
C name dsply
c/exec sql
c+ fetch cr1 into :name
c/end-exec

C enddo

Is This Answer Correct ?    1 Yes 0 No

Thanks gagan for your answer,i'm new to as400,i don't know embedded sql in rpg.can you s..

Answer / ravi

Give DOW SQLCOD =0. There are several other errors with SQLCOD <> 0

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More RPG400 Interview Questions

Can AnyOne tell me how to read join logical file in rpg from starting to end?

2 Answers  


purpose of pannel group??/

2 Answers   CTS,


1.I have a Batch job, Running for 4 hours, i want to reduce the executing time to 2 hours what should you do?

5 Answers   Cap Gemini,


Hi, Can anybody give me real sinario for SFLRCDNBR?with example?

2 Answers  


How do I link an existing logical file to it's Physical File without recompiling?

2 Answers  


Need a sql query: retrieve all duplicate records in table?

1 Answers  


HOW TO DEBUG A BATCH JOB WHEN IT IS IN MESSAGEWAIT(MSWG) STATUS.I KNOW THE STEPS FOR BATCH DEBUGGING,BUT IM CONFUSING WITH WHEN WE SUBMIT ANY JOB FOR BATCH DEBUG WE PUT IN HELD STATE.SO HERE ALSO DO SAME THING OR ANY OTHER WAY,PLEASE HELP ME....

1 Answers   HCL, Mind Tree,


how do I declare a minor?

0 Answers   IBM,


How to print output from openquery in as400 ?

1 Answers   Four soft,


i have 1000 records in pf.what are all the ways to read a particular name records in rpg?? ie.. in pf i have a name called demo appeared around 52 times hw will we read this particular records in rpg/400?.

11 Answers   IBM,


Can we have a Physical file without any member ? Please let me know

12 Answers  


i would like to know under what circumstance the object will get locked on AS400.

5 Answers   IBM,


Categories