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

How can we change element of compile time array?Can we do so

1 Answers   TCS,


why subproc not run in dftactgrp?????/plz explain

2 Answers   CSC,


One of the job in subsystem is in Running status,expected time to complete this job is 2 minutes. But from last 5 -10 minutes this job is still in running status....What are the possible reasons...and What are the actions i need to perform to check this...?

4 Answers  


The PGMA calls PGMB.PGMB generates a report.The report should contain the called program name(PGMA).How do i get the called program name in PGMB to print it on the spool file?(calling program name should NOT be hard coded or passed as parameter to called program?

6 Answers  


1. If there are two programs using same file and 2 users are using the file at the same time and what can be done to allow them both to access? 2. How can remove lock from the file for accessing it by both users?

0 Answers  






what is commitment control?explain about it?

1 Answers   HSBC,


i have 6 char field in program, but this field is using in all files i want to chage field size as 10 char , how can i do this except using *like defn...?

1 Answers   IBM,


What is the diff bw PF/LF Name and their Record format name? what is restriction in record format then file name?

0 Answers   Wipro,


What is the name of default out queue when user logs inn to syatem with valid profile?

3 Answers   IBM,


how we create binder member for updating service program and where we type this code on command line or in program ? strpgmexp pgmlvl(*current) export symbol (xyz0 endpgmexp. plz explain me this step by step .

2 Answers  


How can i keyed a flat file in RPGLE

5 Answers   IBM, Wipro,


1.I have a Physical file with 100 records, No duplicates exists, all are Unique,But while i am running Runqry utility i am getting only 80 records..What could be the reason?

3 Answers   Cap Gemini,


Categories