Version 5.x contains the ability to use stored procedures and logic. You could also look into using lua as your scripting language for MySQL.
-----Original Message----- From: Lourenço de Paula To: [EMAIL PROTECTED] Sent: 6/15/04 11:54 AM Subject: Re: Batch Script Thanks, but can not I use a MySQL native script language like in MS Sql Server and Oracle? ----- Original Message ----- From: "George Chelidze" <[EMAIL PROTECTED]> To: "Lourenço de Paula" <[EMAIL PROTECTED]> Sent: Tuesday, June 15, 2004 1:23 PM Subject: Re: Batch Script here is a quick perl script which isn't tested: -- CUT HERE -- #!/usr/bin/perl use DBI; # define mysql connection information here my ($dbhost, $dbname, $dbuser, $dbpass) = ("localhost", "db", "user", "pass"); my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost", $dbuser, $dbpass) or die $DBI::errstr; my $sql = "SELECT version FROM mytable"; my $sth = $dbh->prepare($sql) or die "prepare() failed. Error = \"" . $dbh->errstr . "\""; $sth->execute or die "prepare() failed. Error = \"" . $dbh->errstr . "\""; my $version = 0; if ($sth->rows == 1) { $version = $sth->fetchrow_array; } $sth->finish; if ($version == 1) { # place correct query for create here $sql = "CREATE TABLE ..."; $dbh->do($sql) or die "do() failed. Error = \"" . $dbh->errstr . "\""; # place correct query for insert here $sql = "INSERT INTO ..."; $dbh->do($sql) or die "do() failed. Error = \"" . $dbh->errstr . "\""; } else { # place correct query for drop here $sql = "DROP TABLE ..."; $dbh->do($sql) or die "do() failed. Error = \"" . $dbh->errstr . "\""; } $dbh->disconnect; -- CUT HERE -- Best Regards, Lourenço de Paula wrote: >Hi, > >In my database I've a table with a field that control de version of may tables, now I need to make a script to update my tables and I would like to make something like that: > >DECLARE > i number; >BEGIN > select version into i from mytable; > if version = 1 then > create table... > insert into... > else > drop table >END; > >I'm using MySQL 4.0.18-max-nt, Have I any way to do it? > >Any help will be usefull > >Thanks. >Lourenço de Paula > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]