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
what was the robotech rpg?
what do you mean by an input subfile, what are the keywords required?
explain sflclr, sflend, sfldlt, and sflcsrrrn?
How can we know running job is batch or interactive?
what is an online rpg?
Interviewer asked me write down DDS for load all subfile .can anybody write dds
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
what is the rpg system?
What are the types of identifiers?
How many program bind in one module....
How to create a login screen using a command instead of display file.... intention is to get a password field on a command..... how do you achieve this...
When we have a file with Duplicate records and I want to read the unique record from the file. For example a file containing Emp Name as 'Ram' and there are 3 entries of it. So how to read a unique record from File?
What is ment by record level identifier?
Program to read marks of 10 students for 4 subjects and compute and display total marks and status of each student in rpg
what is the difference between do while and do until?