Re: sql question
Posted in 1993
Topics: Triggers, Constraints & Referential Integrity
In a recent posting Raskesh Goyal Wrote:
Lots of Stuff Deleted...
>WHEN I RUN MY REPORT, (PER BATCH), I GET 25 PRINTED PAGES OF WHICH ONLY
>4 PAGES HAVE THE INFORMATION THAT I NEED. 21 PAGES ARE WASTAGE. ON
>THOSE 21 PAGES ALL I GET IS THEADER INFORMATION (THE FIELDS ARE ALL
>FALSE THEREFORE THEY DONT PRINT). I WANT TO PRINT ONLY 4 PAGES
>WITH HEADER AND ALL THE FIELD NAMES THAT MATCH IF-THEN (TRUE).
>
More stuff Deleted
>HERE IS PART OF MY REPORT:
>
>DATABASE RADC
>END
>SELECT * FROM RAD101
>WHERE BATCH_ID = "0312"
>ORDER BY PAT_ID>FORMAT
>PAGE HEADER
>PRINT COLUMN 25, "LOGIC CHECK REPORT"
>SKIP 1 LINE
>PRINT COLUMN 25, "RESEARCH DEPARTMENT"
>PRINT COLUMN 10, BATCH_ID
>SKIP 3 LINES
>PRINT COLUMN 10, PAT_ID
>ON EVERY ROW
>IF FIELD_1 = "1" THEN PRINT "FIELD_1"
>ELSE
>IF FIELD_1 = "2" THEN PRINT "FIELD_1" (FIELD_1 HAS 1,2,3 POSSIBLE VALUE)
>....
>I HAVE 10 SIMILAR IF-THEN-ELSE
>
>AT THE END I HAVE
>SKIP TO TOP OF PAGE
^^^^^^^^^^^^^^^^^^^^
This is the problem.
Set up a flag variable then conditionally execute this this line based on the
flag. For example:
LET Page_flag = FALSE
IF ..... THEN
LET FIELD_1 = ...
LET Page_flag = TRUE
END IF
.....
IF Page_flag THEN
SKIP TO TOP OF PAGE
END IF
The flag should be set to TRUE by conditions in your mass of "IF"
statements. While I would recommend trying to filter some of the data to
preclude having to IF things to death, I realize that the situation (DATA)
may not allow this approach.
I guess the point is that ACE will process every record returned by the select
statement in a FORMAT block unless explicity told not to. The SKIP TO TOP OF
PAGE is also triggering the page header to be printed, hence the blank page
with only a header.
Hope this helps.
Jim Sauer
Technology Applications Inc.
ODCSIM-C4IS-STACCS-E
sauerj@heidelberg-emh2.army.mil