[prev in list] [next in list] [prev in thread] [next in thread]
List: mysql
Subject: One question about Perl DBI interface.
From: "webmaster" <webmaster () aztpa ! ru>
Date: 2004-11-30 5:51:58
Message-ID: 000a01c4d6a0$b5a1ae80$340a14ac () aztpa ! ru
[Download RAW message or body]
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.
webmaster@aztpa.ru
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic