Hello Monks.

I am creating some scripts to verify stored procedures. These stored procedures contain print statements meant to organize data for the user.

I have gotten past getting DBD::ODBC to recognize print statements and get them output to the console without throwing an error. Now, I want to now take those SQL PRINT statements and place them in data structures in the same order that they appear on the console. Say to create a file later.

I used this code as my sample to get the statements to the console:

#CREATE THE CUSTOM ERROR HANDLER AND #DO CODE HERE THAT RETURNS PRINT STATEMENT HEADERS #MINGLED WITH RETURNS OF ROWS, I.E.: #Name #JOHN SMITH #Title #MANAGER #Department #FOO BAR #Data from Database my @sp_return_data; #Array to be populated like stored procedure output my @final_output; do { my $line; while (@sp_return_data = $sp_sth->fetchrow_array()) { $line = join (' | ', @sp_return_data) . ".\n"; push @final_output, $line; } } while ($sp_sth->{odbc_more_results});
I don't really understand how to grab the PRINT statements being handled by my custom error handler. My question is:

How do you modify that code snippet to put all of the PRINT statements into the array along with the rows (In order of appearance).

Thank you Monks!


In reply to Saving SQL PRINT statements - MSSQL, SQL Server, DBD::ODBC. by 18th_bronzeman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.