Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
cancel
Showing results for 
Search instead for 
Did you mean: 

Informix- printing to a report

Krista A
Occasional Advisor

Informix- printing to a report

I'm trying to print to a report using a cursor, but for some reason, when I step through the program, I see that wehern it reaches this line of code:
foreach curs into rpt.*
it skips the loop...

here's my related code:

let str = "select a.wc, a.cc, a.bn, a.in, b.id
, b.bs, a.ps from table1 a, table2 b"

start report attachedBilling to "attached_billing.out"
prepare datacurs from str
declare curs cursor for datacurs
foreach curs into rpt.*
display "Processing. Please wait...." at 6,10
output to report attachedBilling(rpt.*)
end foreach
finish report attachedBilling

Any idea why it seems to be not fetching any info from the cursor?

Thanks in advance!
4 REPLIES
Steve Lewis
Honored Contributor

Re: Informix- printing to a report

Its been a while since I did this ancient language but I can think of a couple of possible reasons.

1. check that you do have some data in your tables! The symptoms are consistent with a NOTFOUND from your select.
2. add a WHERE clause to your SQL to join the tables together.

Check your whenever error statement to get more debug info.
Also try sending the report to a pipe or something else and put displays in the report section itself.


Krista A
Occasional Advisor

Re: Informix- printing to a report

I'm still having problems with this. The select statement does actually select a record from the table- I was able to print it out. But for some reason, the cursor seems to not be fetching the data from the select statement.
Any ideas?
Thanks!
Peter Godron
Honored Contributor

Re: Informix- printing to a report

Krista,
do you have to issue a specific open command ?:
open curs
foreach curs into rpt.*


Also I would change the names to avoid any potential reserved word problem. So str => qstring and curs => dcursr
Krista A
Occasional Advisor

Re: Informix- printing to a report

The last time I wrote a program that wrote to a report, I didn't have to use an open command. Though there is a way to do it that way, also. I tried it that way with this program, and I'm still having the same problem.

I also did what you suggested- to change the name of the cursor and the select string as to not confuse the program in case there were any preset system variables, but I still get null printed out to the report..