in reply to Batch DB query -- implementation?

You have answered your own question:
although some databases and drivers do support this (notably Sybase and SQL Server).
From the documentation for DBD::Sybase:
DBD::Sybase has the ability to handle multi-statement SQL commands in a single batch. For example, you could insert several rows in a single batch like this:
$sth = $dbh->prepare(" insert foo(one, two, three) values(1, 2, 3) insert foo(one, two, three) values(4, 5, 6) insert foo(one, two, three) values(10, 11, 12) insert foo(one, two, three) values(11, 12, 13) "); $sth->execute;
____________
Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Batch DB query -- implementation?
by zaimoni (Beadle) on Jul 03, 2002 at 16:13 UTC

    DBD::Sybase isn't even installed :)

    Within the DBI, the target modules that I immediately need verified are DBD::ODBC (the gateway I'm currently using to MS SQL Server) and DBD::MySQL. I am biased negative on DBD::MySQL, since I have already experimented with the following:

    'DELETE FROM UberTable WHERE WonderVar=?; OPTIMIZE UberTable'
    and variants, which crash when sent through the DBI.

      I don't know if you made the mistake because it's just off the top of your head, but the syntax is OPTIMIZE TABLE tablename. Note you can send it in a seperate query anyway, So far, nothing DBI-related here..

      I think what you have to understand is that DBI intentionally keeps a low feature profile and avoids trying to be intelligent. It caters mostly to the lowest common denominator, trying to make sure that itself is, to the extend possible, entirely DBMS-independent. However, the programmers of drivers are encouraged to implement interfaces to DMBS-dependent features in their module for those who wish to take advantage of unportable features.

      So the place to find your answers is the driver's POD. DBD::ODBC mentions "multiple result sets" a fair number of times, so I'd say it's safe to assume it supports what you want. The changelog says the distribution comes with tests for multiple result sets, so fetch the tarball from CPAN and look at the included tests (the .t scripts in the t/ directory) to for example source.

      Of course, as everyone else has told you, you may well find yourself looking at a negligible performance increment..

      Makeshifts last the longest.