A few comments about your code:
... looks a little odd to me. It seems to suggest that you are passing a list of statements, rather than a single one?# execute the sql statement $sth=$dbh->prepare("@sql");
Also, you appear to be selecting at least 14 rows of data, yet you only use 6 of them. What is the point of that? Are you doing select * from ... or something?
I strongly suspect that your code could be significantly simplified by improving your SQL select statement to only return the data that you actually need to use. Perhaps you could post that along with a sample set of data?
Cheers,
Darren :)
Update: One thing that I forgot to mention is that your choice of variable names makes your code a little difficult to follow. Stuff like $aa = $rec[0]; doesn't really tell you much about the data. It's a personal thing, but I usually try to make my variable names as descriptive as possible - makes it easier for the next person who comes along and has to debug/maintain my code (usually me) :)
That's one reason why I like to use selectall_hashref on the results of my DB queries. I can then refer to the data in a very descriptive way.
In reply to Re: Direct to spreadsheet
by McDarren
in thread Direct to spreadsheet
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |