Re: Report Question
Posted in 1998
Topics: Stored Procedures & SPL
On 15 Dec 1998 15:28:17 GMT, "Bryan Sapot" <bsapot@NO_SPAM.lawless-tech.com> wrote: >Can you call a FUNCTION from in side a REPORT. > Oh yes indeedy, I call functions all the time within REPORT's. >Some thing like this > >REPORT thisreport() > > ON EVERY ROW > PRINT "something" > CALL thisfunc() > >END REPORT > >FUNCTION thisfunc() > PRINT "something else" > >END FUNCTION > Ah, don't think you can do this, certainly not with RDS 4.20. PRINT statements can only be used with REPORT functions. I tried getting round this with the following example: define p_flag smallint main let p_flag = 0 start report rep1 to file "rep1.out" start report rep2 to file "rep2.out" display "first rep1" output to report rep1 () display "second rep1" output to report rep1 () finish report rep1 finish report rep2 end main function f1() let p_flag = p_flag + 1 output to report rep1() end function report rep1() format on every row display "in on every row, p_flag = ", p_flag if p_flag = 0 then call f1() end if if p_flag = 1 then print "p_flag = 1" end if print "report 1" output to report rep2() end report report rep2() format on every row print "report 2" end report $ What I go back on my screen was: first rep1 in on every row, p_flag = 0 in f1 second rep1 I had expected to see another line saying: in on every row, p_flag = 1 But it would appear that my second call to rep1 within the MAIN function never made it to the ON EVERY ROW section. Anyone know why? Cheers, Hamish.