Hi,

I've got a pesky little problem that I've been staring at for too long, so I
hope you guys can help me out...

I need to reformat the output (result set) of an SQL query, using
Win32::ODBC. The result set looks like this:

Server1 JobResult1
Server1 JobResult2
Server1 JobResult3
Server2 JobResult1
Server2 JobResult2
Server2 JobResult3
Server2 JobResult4
Server3 JobResult1
Server3 JobResult2
Server4 JobResult1
Server4 JobResult2
Server4 JobResult3
[etc]

The server names and the number of job results per server vary, and
JobResult is a string (successful, failed, unknown)

The desired format looks like this: 

Server1 JobResult1 JobResult2 JobResult3
Server2 JobResult1 JobResult2 JobResult3 JobResult4
Server3 JobResult1 JobResult2
Server4 JobResult1 JobResult2 JobResult3
[etc]

To get this result, I'd have to buffer the JobResult strings in a temporary
array until the server name changes, so that I can print that name and the
contents of the array as a single line of data. Furthermore I would have to
loop through the data once without printing anything to set the necessary
variables, and I would have to read one line past the end of the data to
print the last line. 

I've included what I cobbled together as an attachment. It queries a table
in an SQL database and prints lines with a unique server name and one job
result, so obviously something's crooked and grinning widely into my face. I
just don't see the bodged line(s) of code anymore ;-(  

Thanks for any help,
Marco

Attachment: querydb.pl
Description: Binary data

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to