in reply to Re: How should I handle $sth->execute() errors?
in thread How should I handle $sth->execute() errors?

You can do this in SQLite ... but regardless of which DBD you use*, this technique will fail if the table is already gone when you issue the DROP command. It works like a charm if you add the drop statement after your code yacks the first time you try to ADD a table that already exists -- but as soon as something else DROP's the table, your script breaks "in the opposite direction," so to speak. I think mifflin's suggestion of "catching an exception" by trapping inside eval is a more robust solution.

* unless you are using something like MySQL that offers CREATE TABLE foo IF NOT EXISTS ...

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
  • Comment on 2Re: How should I handle $sth->execute() errors?

Replies are listed 'Best First'.
Re: 2Re: How should I handle $sth->execute() errors?
by Art_XIV (Hermit) on Dec 04, 2003 at 16:36 UTC

    You'll get no arguments from me concerning error-handling. I just had a sense that the poster was not familiar with the DROP/CREATE idiom in datababase build scripts. :)

    Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"