Focal Point
Checking whether data exists or not..?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5851068331

June 02, 2005, 06:44 PM
<delvegas>
Checking whether data exists or not..?
Hi guys,
How can we check whether data data exists in Hold file or not..?

-SET &ECHO = ALL;
TABLE FILE EMPLOYEE
SUM EMP_ID
BY LAST_NAME
WHERE LAST_NAME EQ '&ENTER' ;
ON TABLE HOLD AS FIRST FORMAT ALPHA
END

-- NOT BY PRINTING THE DATA IN "FIRST"

THANKS IN ADVANCE
June 02, 2005, 07:33 PM
codermonkey
Hi,
put a -RUN after your END statement for the TABLE FILE and check the value in &RECORDS.

If there were no records returned &RECORDS WILL BE 0.
June 02, 2005, 08:27 PM
reFOCUSing
If you ever plan to do a 'WHERE TOTAL' in your code I would use &LINES.

Here is an example of where &RECORDS will not work:
TABLE FILE CAR
SUM
DEALER_COST
RETAIL_COST
BY CAR
WHERE TOTAL RETAIL_COST EQ 0
ON TABLE HOLD AS H0 FORMAT ALPHA
END
-RUN
-TYPE LINES: &LINES
-TYPE RECORDS: &RECORDS
June 02, 2005, 09:17 PM
<delvegas>
Thanks guys,
Solved the problem
Really appreciated.

I have one more problem which is more complex..one

Hi

Unable to figure out the problem:- User enter's 2 Test ID. like &STestRequest(100),&CTestRequest (200) and process the request.

-SET &TestRequest = &STestRequest;
! mkdir /tmp/data
! mkdir /tmp/data/A&TestRequest
APP MAP HOLDIR /tmp/data/A&TestRequest
APP HOLD HOLDIR
FILEDEF B&TestRequest DISK /tmp/data/A&TestRequest/B&TestRequest...foc (
use
/tmp/data/A&TestRequest/B&TestRequest (database location)
END
-RUN
-* ----------------------------------------------first test Request
TABLE FILE B&TestRequest
SUM
COUNTRY
WHERE FK_ID EQ &TestRequest
END
-RUN

-IF &RECORDS EQ 0 THEN GOTO WARN1 ELSE WARN1;
"Message Data Exists- for first"
-WARN1
"Message NO Data Exists- for first"

-* ----------------------Problem for this part of code at setting path while processing 2nd request (&CTestRequest)

-SET &TestRequest = &CTestRequest;
APP HOLD
! mkdir /tmp/data
! mkdir /tmp/data/A&TestRequest
APP MAP HOLDIR /tmp/data/A&TestRequest
APP HOLD HOLDIR
FILEDEF B&TestRequest DISK /tmp/data/A&TestRequest/B&TestRequest...foc (
use
/tmp/data/A&TestRequest/B&TestRequest (database location)
END
-RUN
-*------------------------------------------------Second Test Request
TABLE FILE B&TestRequest
SUM
COUNTRY
WHERE FK_ID EQ &TestRequest
END
-RUN

-IF &RECORDS EQ 0 THEN GOTO WARN2;
"Message Data Exists- for Second"
-WARN2
"Message NO Data Exists- for Second"
-EXIT
-------------------------------------------------

Problem is :- For the first test request code (say 100) code is working fine and displaying the message correctly, but for second Test Request (say 200).. It unable to locate to the file where database exists, and always display the message " NO Data Exists ", even though data exists.

ANY SUGGESTION IS APPRECIATED.

Thanks in Advance