|AS400 Interview Questions and Answers Part14
Q1: What is the main use of OPNQRYF? Why should we use OVRDBF SHARE(*YES)?
OPNQRYF will select those records which are going to be processed by the program, By using the Open Query File (OPNQRYF) command, you can open a file to a set of database records that satisfies a database query request. The OPNQRYF command allows you to perform many data processing functions on database files. it acts as a filter between the processing program and the database records.
We use OVRDBF SHARE(*YES) to use the open data path (ODP) created by the Open Query File (OPNQRYF) command.
Q2: How to insert data in PF by using the CL program?
In CL, we can use the RUNSQLSTM command to execute the SQL Insert statement to insert data in PF.
Q3: define the purpose of the LEAVE operation?
LEAVE operation will be used inside loops. Once the LEAVE opcode gets executed it will transfer the control after the ENDDO and it will execute the next line just after the ENDDO.
Q4: How to get the number of records in a file in RPG without the CL command?
D NUM_RCDS 156 159I O*Num of records
Q5: How do you use Commitment control in the RPG program?
COMMIT command is used to commit the changes we perform in a database. For using commitment control we need to journal the file.