If you run a script with
mysql < script.sql
then if there's an error, the script dies.
If you run a script with
mysql -e "source script.sql"
Then the script will just spit out an error and move on to the next command.
Hopefully that will help.
-Sheeri
On 5/24/06, Daevid Vincent <daevid@stripped> wrote:
> Semi related to this, as it appears in my searching that this is
> unfortunately not a supported feature. Is there a flag or something that I
> can put in my .sql file that will turn OFF any error checking, execute my
> statements (so that even if one fails, the next one will be tried), then
> turn it back on again at the end of the file? Sort of like how you can do
> the "SET FOREIGN_KEY_CHECKS=0;" so something akin to "SET ERROR_CHECKS=0;"
> or "SET FORCE=1;"
>
> And, yes, I do know that there is a --force option for the importing, but I
> cannot use that in my case. This is an automated script and generally I want
> the SQL to fail on any errors b/c then I know the upgrade is hosed. This is
> a special case where some people got a SQL upgrade (by hand) and some
> didn't, hence the discrepency between the schemas.
>
> DÆVID
>
> > -----Original Message-----
> > From: Daevid Vincent [mailto:daevid@stripped]
> > Sent: Wednesday, May 24, 2006 12:13 PM
> > To: mysql@stripped
> > Subject: How do I add a column only if it doesn't exist?
> >
> > I want to do something like this:
> >
> > if not exists `hotel_page_templates`.`hpt_custom_fields`
> > alter table `hotel_page_templates` add column
> > `hpt_custom_fields` text after
> > `hpt_alternate_username`;
> >
> >
> > ÐÆ5ÏÐ
> >
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:
> > http://lists.mysql.com/mysql?unsub=1
> >
> >
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=1
>
>