1.Load an runtime array of length 99 from the pf and you
want to handle all the possible errors?
Answer / sagar wagh
H DFTACTGRP(*NO) ACTGRP(*NEW)
Dcl-F EMPPF DISK; // Declare the physical file
Dcl-S EmpArray CHAR(10) DIM(99); // Declare the runtime array
Dcl-S Index INT(10); // Declare an index for the array
Dcl-S ErrorMsg CHAR(100); // Declare a variable for error messages
// Main logic
C/EXEC SQL
C+ DECLARE C1 CURSOR FOR
C+ SELECT EMPNO FROM EMPPF
C/END-EXEC
C/EXEC SQL
C+ OPEN C1
C/END-EXEC
Index = 1;
DoU Index > 99;
C/EXEC SQL
C+ FETCH C1 INTO :EmpArray(Index)
C/END-EXEC
If SQLCOD = 100; // No more records
Leave;
ElseIf SQLCOD <> 0; // Handle SQL errors
ErrorMsg = 'SQL Error: ' + %Char(SQLCOD);
Dsply ErrorMsg;
Leave;
EndIf;
Index += 1;
EndDo;
C/EXEC SQL
C+ CLOSE C1
C/END-EXEC
| Is This Answer Correct ? | 1 Yes | 1 No |
Can you copy the records created by the OPNQRYF to other files and how?
What is significance of a file designated as a Primary file in Rpg400 program....also what's use of secoundry file
what is flat file?
what is an online rpg?
What is the name of default out queue when user logs inn to syatem with valid profile?
Errors in Sql query will be in which state?
I want to add 10 days in current date. how it is possible in CL program...?
Interviewer asked me write down DDS for load all subfile .can anybody write dds
Have a join logical file with more than one members with different record formats. So how can we read the different members from this file and also how we can read the different record format from the join logical?
What is difference between bind by copy and bind by reference?
how to find whether a date format is valid or not in RPG400 not in RPGILE.Can you please write the coding for this sir,i'm new to AS400.Please help.
Suppose we add one field in physical file and this physical file is used by several programs.how do we know which program is using that file? What are the impact analysis.