>I used perl to run sql commands from a Text file, it always can't finish
>totally and report error in unstable lines .
>The error report that sql syntax error, but the syntax is same, just same,
>and many sql lines;
>Would you please tell me what this happen and how to resolve it?

What you ought to do is use perl to parse the file and run the commands
individually.

use DBI;
my $driver="mysql";
my $database="database";
my $user="username";
my $password="password";
my $dns = "DBI:$driver:database=$database";
my $db=DBI->connect($dns, $user, $password);

open SQL, $ARGV[0];
open ERRORS, ">errors.sql";

while (my $line = <SQL>) {
        $line =~ s/;$// ;
        $db->do($line);
        if $db->err {
                write ERRORS, $line . ";\n";
        }
}
$db->disconnect;
close SQL;
close ERRORS;

That would execute all of the statements that were legal, and put any
errored statements in a separate file for you to clean up at your leisure.

More elaborate parsing would be required if the statements were multi-line.

Daniel J McDonald, CCIE 2495, CNX
Principal Network Specialist
Digicon Technologies
http://www.digicontech.com

Digicon, a Cisco Partner, Silver Certified.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to