At 7:54 PM -0700 5/19/01, Cindy wrote:
>OK, let's say you've got the case where you construct an INSERT
>statement to put a new entry into an existing table.  But the
>formatting is wrong (you're short one field in the entry).
>
>What's the code in perl to catch that problem, assuming you've been using
>perl to construct the string and then use the mysql dbi functions to
>interface with mysql?  (See below).
>
>I start it with:
>
>
>$db_handle = DBI->connect('DBI:mysql:database=*****_DB;host=mysql;',
>                          '*****', '********', {RaiseError => 1,
>                          AutoCommit => 1});
>
>I then construct the mysql statement (an insert statement) and call:
>
>$db_handle->do($db_input);

If you want to catch the problem, then you should leave RaiseError
disabled.  Enabling it causes DBI to catch the error itself and
print an error message by calling die().

When you leave RaiseError disabled, you're responsible for checking
for errors, but then you also can catch them:

$db_handle->do($db_input) or handle_error();

>
>Thanks,
>--Cindy
>--
>[EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail <[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-- 
Paul DuBois, [EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to