Focal Point
No rows in Web Focus

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

April 19, 2006, 09:27 AM
Karanth
No rows in Web Focus
I am doing something like this

TABLE FILE
COUNT *
WHERE
END

It gves me the count if there are records matching the condition but if there are no records i want it to print

COUNT *
-------
0

Is this possible?
April 19, 2006, 09:44 AM
Kamesh
Hope this is what you are trying to do,

TABLE FILE CAR
COUNT *
WHERE CAR EQ 'BMW'
ON TABLE HOLD AS TEST
END
-RUN

-IF &LINES EQ 0 THEN GOTO SHOW ELSE GOTO SHOW1;
-SHOW
-TYPE ZERO RECORDS
-EXIT
-SHOW1
-TYPE &LINES RECORDS
-EXIT


WFConsultant

WF 8105M on Win7/Tomcat
April 19, 2006, 09:56 AM
Karanth
No this is not what i want. Basically i want the report to be in a hold file with the value 0..

In the sense
TABLE FILE ABC
COUNT *
WHERE FALSE CONDITION
ON TABLE HOLD AS H2
END

TABLE FILE H2
PRINT *
END

OUTPUT SHOULD BE

COUNT(*)
--------
0
April 19, 2006, 10:11 AM
<Special-K>
Why dont you define a field and use SUM?

DEFINE FILE CAR
WCOUNT/I5 = IF THEN 1 ELSE 0;
END

TABLE FILE CAR
SUM WCOUNT
END
April 19, 2006, 10:14 AM
Tony A
If all you want is for WF to show the report and not a screen showing no records e.g. No HTML Output NUMBER OF RECORDS IN TABLE= 0 LINES= 0, then you can SET EMPTYREPORT = ON.

This will ensure that the report is always shown but if you have no output for your report then the report will just be blank with column headings (and not show your suggestion of 0 under the COUNT column heading)!

The common method of achieving an empty report scenario is to issue a -RUN after your report and then check the value of &LINES. If the value is zero then redirect the code stream to an HTMLFORM that displays a report stating that the selection criteria produced no records. If the report has data to be shown then just show the report as usual -
-*SET EMPTYREPORT = ON
TABLE FILE CAR
WRITE CNT.MODEL
WHERE COUNTRY EQ 'CHINA'
ON TABLE PCHOLD AS MYREPORT FORMAT HTMLTABLE
END
-RUN
-IF &LINES EQ 0 THEN :NoReport;
-* If the code stream gets here then the report will be displayed
-HTMLFORM MYREPORT
-GOTO :NowExit;
-:NoReport
-HTMLFORM BEGIN
<html><head><title>Emptry Report</title></head>
<body>
The selection criteria produced no data for the report
</body></html>
-HTMLFORM END
-:NowExit


Of course you can go one step further and check for &FOCERRNUM being non zero and redirect to an HTMLFORM showing that the code had errors within it as well, but I'll leave you to work that one out Wink.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 25, 2006, 01:31 AM
Karanth
Thanks Tony. It worked.