Multiple statements within one $dbh->do()

Multiple statements within one $dbh->do()

am 15.08.2007 01:47:43 von Peter.Loo

------_=_NextPart_001_01C7DECD.824ED37F
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi,
=20
I am trying to execute two SQL statements within one call to $dbh->do()
and Perl DBI is not happy.
=20
Here is a sample call:
=20
$sql =3D qq{delete from some_table=20
where condition_one=20
and condition_two;=20
insert into some_table (col_1, col_2, col_3)=20
select col_1, col_2, col_3=20
from another_table
where condition_one
and condition_two;};
=20
Is this possible?
=20
I have used multiple statements in the ODBC driver but have not done so
in the Oracle driver. Oracle driver is not working.
=20
Thanks.
=20
Peter

------_=_NextPart_001_01C7DECD.824ED37F--

RE: Multiple statements within one $dbh->do()

am 15.08.2007 02:24:38 von Philip.Garrett

Loo, Peter # PHX wrote:
> Hi,
>=20
> I am trying to execute two SQL statements within one call to
> $dbh->do() and Perl DBI is not happy.
>=20
> Here is a sample call:
>=20
> $sql =3D qq{delete from some_table
> where condition_one
> and condition_two;
> insert into some_table (col_1, col_2, col_3)
> select col_1, col_2, col_3
> from another_table
> where condition_one
> and condition_two;};
>=20
> Is this possible?
>=20
> I have used multiple statements in the ODBC driver but have not done
> so in the Oracle driver. Oracle driver is not working.


With Oracle, you can use an inline PL/SQL block:

$sql =3D qq{
begin
delete from ...;
insert ...;
end;
};

- Philip

RE: Multiple statements within one $dbh->do()

am 15.08.2007 16:14:04 von Peter.Loo

Thanks. I don't know what I did wrong the first time, but now it is
working. Thanks again.
=20
Peter

-----Original Message-----
From: Garrett, Philip (MAN-Corporate)
[mailto:Philip.Garrett@manheim.com]=20
Sent: Tuesday, August 14, 2007 5:25 PM
To: Loo, Peter # PHX; dbi-users@perl.org
Subject: RE: Multiple statements within one $dbh->do()

Loo, Peter # PHX wrote:
> Hi,
>=20
> I am trying to execute two SQL statements within one call to
> $dbh->do() and Perl DBI is not happy.
>=20
> Here is a sample call:
>=20
> $sql =3D qq{delete from some_table
> where condition_one
> and condition_two;
> insert into some_table (col_1, col_2, col_3)
> select col_1, col_2, col_3
> from another_table
> where condition_one
> and condition_two;};
>=20
> Is this possible?
>=20
> I have used multiple statements in the ODBC driver but have not done=20
> so in the Oracle driver. Oracle driver is not working.


With Oracle, you can use an inline PL/SQL block:

$sql =3D qq{
begin
delete from ...;
insert ...;
end;
};

- Philip


This E-mail message is for the sole use of the intended recipient(s) and
may contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply E-mail, and
destroy all copies of the original message.