Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Thanks!

I experimented, and the following

{ local $sth->{TraceLevel} = "2|SQL"; $rv = $sth->execute(@args) or die $sth->errstr; }

Produced the desired output, unfortunately surrounded by some verbose lines (see second paragraph). Reducing the trace level eliminated the information.

DBI::st=HASH(0x2910b18) trace level set to 0x100/2 (DBI @ 0x0/0) i +n DBI 1.623-ithread (pid 7420) -> execute for DBD::mysql::st (DBI::st=HASH(0x2910ab8)~0x2910b18 ' +xLangsdorf') thr#309f18 Called: dbd_bind_ph -> dbd_st_execute for 02497600 >- dbd_st_free_result_sets <- dbd_st_free_result_sets RC -1 <- dbd_st_free_result_sets mysql_st_internal_execute MYSQL_VERSION_ID 50147 >parse_params statement SELECT * FROM ksr_bf_utf8.t_user_portal WHERE f_client = ? Binding parameters: SELECT * FROM ksr_bf_utf8.t_user_portal WHERE f_client = 'xLangsdorf' <- dbd_st_execute returning imp_sth->row_num 19 <- execute= ( 19 ) [1 items] at placeholder.pl line 57 -> STORE for DBD::mysql::st (DBI::st=HASH(0x2910b18)~INNER 'TraceL +evel' 0) thr#309f18 -> dbd_st_STORE_attrib for 02497600, key TraceLevel <- dbd_st_STORE_attrib for 02497600, result 0 <- STORE= ( 1 ) [1 items] at placeholder.pl line 56

So I'd need to redirect the trace to a variable and parse the output for a paragraph starting with 'Binding parameters: ' in case of error...

something like

open my $trace_fh, ">", \ my $trace_out; { $sth->trace("2|SQL", $trace_fh ); $rv = $sth->execute(@args) or die parse($trace_out) . "\n" .$sth->errstr; }

Thanks again! :)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!


In reply to Re^2: DBI.pm: composing and debugging MySql placeholders by LanX
in thread DBI.pm: composing and debugging MySql placeholders by LanX

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-28 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found