# Mysql errors and Perl



## clinty (Jun 12, 2009)

Hello.

I use MySQL and shell Scripts to make some jobs. However, Shell is not a good idead to make some queries like SELECT. So, I'm testing Perl. It's better, but I have only one question:

I use this Packagefor MySQL databases. Is it possible to print a msg/stop the program/die the script when the query fail?

Example:


```
$q = 'SELEEEECT * FROM table;';
$link->query($q)
```

This query will fail because SELEEECT is not a valid MySQL command. And Perl does not print msg error.

In PHP, is that possible to do this thing:


```
$q = 'SELEEEECT * FROM table;';
mysql_query($q) or die(mysql_error())
```

Is that possible in Perl, with Mysql.pm ? I tried die() function, but noting is printed.

Thanks for your advices.


----------



## crsd (Jun 12, 2009)

Did you check documentation for p5-DBD-mysql?

check EXAMPLES section at least - http://search.cpan.org/~capttofu/DBD-mysql-4.010/lib/DBD/mysql.pm#EXAMPLE


----------



## clinty (Jun 12, 2009)

I do not use p5-DBD-mysql, I use http://search.cpan.org/~capttofu/DBD-mysql-3.0008/lib/Mysql.pm.


----------

