1.Load an runtime array of length 99 from the pf and you
want to handle all the possible errors?
Answer Posted / 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 |
Post New Answer View All Answers
Program to read marks of 10 students for 4 subjects and compute and display total marks and status of each student in rpg
How do u design a physical file, when you have 2 Unique fields like for eg in A student file student ID and student examination no both are unique
how do you use commitment control in rpg?
How would display prime numbers using CL program?
how do I declare a minor?
how can you display specific subfile page on the screen in unequal subfile?
What is difference between bind by copy and bind by reference?
What is file identifier where we can use?
How to write record if no field or the field are different in physical file in rpgle ?
how can I tell when to replace the array?
what is the difference between do while and do until?
is this a rpg channel?
Suppose we have one database file and it is used by 5 programs and in 3 program we have to add some records in datbase file s what is the impact on other program?
what is the necessary keyword needed to scroll subfile records?
what is a rpg?