Good morning!

Important: SQL Server used: MySQL (version 4.0.17) on UNIX FreeBSD.

Answer this question please:
Can I make a request, consisting of several SQL commands at one step, like this:
use DBI; 
my $db = DBI->new();
$db = DBI->connect(...) or die "Can't connect to DataBase:", "error code", 
"\n"; 
$db->do("CREATE TEMPORARY TABLE tmptable (field1 INT(4) UNSIGNED ZEROFILL 
DEFAULT '0000' NOT NULL,field2 DOUBLE(16,2) DEFAULT '0.00' NOT NULL); LOCK 
TABLES table1 read; INSERT INTO tmptable SELECT field1, MAX(field2) FROM table1 
GROUP BY field1;"); 

I can do it by sending these commands one by one in series, like this:
use DBI; 
my $db = DBI->new();
$db = DBI->connect(...) or die "Can't connect to DataBase:", "error code", 
"\n"; 
$db->do("CREATE TEMPORARY TABLE tmptable (field1 INT(4) UNSIGNED ZEROFILL 
DEFAULT '0000' NOT NULL,field2 DOUBLE(16,2) DEFAULT '0.00' NOT NULL);"); 
$db->do("LOCK TABLES table1 read;"); 
$db->do("INSERT INTO tmptable SELECT field1, MAX(field2) FROM table1 GROUP BY 
field1;");

I think last solution is more time expensive.

#########################
Truly yours
Sviridov Vladislav.
[EMAIL PROTECTED]

Reply via email to