Hi Baron,
I will read about sql_mode. Also you scripting method sounds great.

I will check on that.

regards
anandkl


On 5/21/07, Baron Schwartz <[EMAIL PROTECTED]> wrote:

Hi,

You could change your server's SQL mode to be as restrictive as possible
(STRICT_TRANS_TABLES, etc) so the scripts cause errors, instead of
warnings.  Read the
MySQL manual section on SQL mode and decide which things you want to throw
errors.  Not
all things can be changed to errors; you will still have the possibility
of some warnings.

Note that you can change the SQL mode for just the current connection; it
doesn't have
to be server-wide.

By the way, did you notice from the output of ? in the mysql client that
you can
instruct it to automatically print warnings when they exist?

You could also write a small script to parse the SQL file from your
engineers into
individual commands separated by blank lines, and execute them one at at
time, catch
errors, and if there's an error print out the statement that caused it.  I
wrote a Perl
module to do this at my employer.  I use it to run batch commands.  If you
do this,
take a look at the DBD::mysql documentation; there is a place where the
warning count
is exposed, and you can examine this after each command and see if it
raised any
warnings.  I wrote code to treat this just like an error: fetch and print
the warnings,
then exit with an error.

Cheers
Baron

Ananda Kumar wrote:
> Hi Baron,
> I cannot do this, becuase the file would be given by engineers and to be
> applied on mysql and i need to inform them about any error after i apply
> them in mysql db.
>
> regards
> anandkl
>
>
> On 5/21/07, Baron Schwartz <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> I see now -- you want to see which commands were executed from the file
>> you sourced.
>> As far as I know you cannot do this.  You could add some debugging
>> statements in the
>> file, like
>>
>> SELECT 'about to drop the table';
>>
>> Then in the output you will see this, and it may give you a hint as to
>> where the error
>> happened.
>>
>> Baron
>>
>> Ananda Kumar wrote:
>> > Hi Baron,
>> > This will give only the results of the command. It does not include
sql
>> > statement.
>> > I need the sql statement to know which sql errored out.
>> >
>> > Database changed
>> > +----------+
>> > | count(*) |
>> > +----------+
>> > |        5 |
>> > +----------+
>> > 1 row in set (0.00 sec)
>> >
>> >
>> >
>> > On 5/21/07, Baron Schwartz <[EMAIL PROTECTED]> wrote:
>> >>
>> >> Hi,
>> >>
>> >> Ananda Kumar wrote:
>> >> > Hi All,
>> >> > I am executing a script from  mysql prompt as below
>> >> >
>> >> > mysql > source ddl.txt
>> >> >
>> >> > I want to spool the out put of the above command to a file along
>> with
>> >> the
>> >> > sql statments. Can you please let me know what parameter should i
>> set
>> >> for
>> >> > the this.
>> >>
>> >> Use the 'tee' command in the mysql client.  Press ? in the client
and
>> it
>> >> will give you
>> >> instructions.
>> >>
>> >> Baron
>> >>
>> >
>>
>> --
>> Baron Schwartz
>> http://www.xaprb.com/
>>
>

--
Baron Schwartz
http://www.xaprb.com/

Reply via email to