top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How MySQL handles Exception Handling ?

0 votes
225 views
How MySQL handles Exception Handling ?
posted Jun 20, 2014 by Amritpal Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Exception handling means changing the usual expected flow of the code. This needs to be done to avoid errors. The exceptions in MySql can be handled using the following syntax:

DECLARE handler_type (Continue | Exit) HANDLER FOR condition_value[,...] sp_statement

Here, whenever an error occurs, the handler type value will decide whether to continue or Exit. Continue will execute the next Sql statement while exit will exit the procedure. Condition_value can take number of levels of categories. set condition is used to define code to be performed if the handler is called.

answer Jun 23, 2014 by Rahul Mahajan
Similar Questions
0 votes
$dbh = DBI->connect("dbi:mysqlPP:$dsn;host=$host", $user, $pw,
{PrintError => 1, RaiseError => 1});
if (!$dbh) {
    print "error: connection: $DBI::errn$DBI::errstrn$DBI::staten";
 }
$drh = DBI->install_driver("mysqlPP");
$ary_ref = $dbh->selectcol_arrayref("SELECT pui,spuid FROM inven WHERE dispatchdate="0000-00-00" and dupli is NULL LIMIT 0, 5000", { Columns=>[1,2] });
 %masterdb = @$ary_ref; # build hash from key-value pairs so $hash{$id} => name
$sth = $dbh->prepare("SELECT DISTINCT spuid FROM inven WHERE dispatchdate"0000-00-00" and dupli is NULL LIMIT 0, 1000");
 $sth->execute();
while ( @row = $sth->fetchrow_array ) {
    push(@dspu, "@row.dat");
}

The above code which uses mysqlPP module is giving our of memory exception and not getting executed. Where as if it uses ODBC connection it is working without any exception. First query will fetch 3000 records and 2nd query fetches 500 records. it may increase in later stages.

 $dbh = DBI->connect("dbi:ODBC:$dsn", $user, $pw,
{PrintError => 1, RaiseError => 1});
if (!$dbh) {
    print "error: connection: $DBI::errn$DBI::errstrn$DBI::staten";
}

Is there any bug in mysqlPP? or am i missing something obvious.

0 votes

Is it possible to connect database with c code, if yes then how?

If possible share the sample code for connecting to a MySQL database and run a sample query....

...