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

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.

4 Answers   HCL,


How can we find out whether the job is interactive or Batch through RPG program? 2) How can we find out through CL program?

6 Answers   CSC,


Can more than one subfile record be displayed on one line?

7 Answers   IBM,


can anybody explain significance of *loval setll with example code????

3 Answers   HSBC,


how to check on which PF , the LF is dependant ?

4 Answers   IBM,


How do you proceed in case your active AS400 session has got disconnected suddenly, how can you get back to your session ? Is it possible??

1 Answers  


What is the purpose of Panel Groups?

4 Answers  


What is the difference between copybooks and subprocedures in as400?

0 Answers  


What is the difference between RPG/400 and RPG4

1 Answers   HCL,


A rpg or clp command to find if the file field is defined as a character or numeric field.

1 Answers   IBM,


can anyone say,what is the use of operation extended H/N/P?

2 Answers  


can we use cl programming to update or delete physical files

12 Answers  


Categories