Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Program to read marks of 10 students for 4 subjects and compute and display total marks and status of each student in rpg

1151


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

1020


how do you use commitment control in rpg?

1287


How would display prime numbers using CL program?

6331


how do I declare a minor?

1165


how can you display specific subfile page on the screen in unequal subfile?

1159


What is difference between bind by copy and bind by reference?

2481


What is file identifier where we can use?

1135


How to write record if no field or the field are different in physical file in rpgle ?

970


how can I tell when to replace the array?

1222


what is the difference between do while and do until?

1259


is this a rpg channel?

1177


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?

1929


what is the necessary keyword needed to scroll subfile records?

1161


what is a rpg?

1203