DBD::Oracle accessing Global Temporary Tables in PL/SQL.

DBD::Oracle accessing Global Temporary Tables in PL/SQL.

am 02.04.2008 02:39:57 von rk_lj

Hi

Just wondering if I should be able to prepare a PL/SQL statement that bot=
h
creates a temporary table and accesses that temp table in the one prepare
execute and bind statements, or am I going to need to do more than one pr=
epare.
Due to access I am unable to create functions or procedures on the datab=
ase
but temp tables are ok. eg below I want to end up being able to bind to =
:test
to fetch my results, but I want to be able to prepare and execute the bel=
ow in
one go. .. Thanks in advance for any help... This works in sqlplus in =
the
one statement but DBD Oracle is seeing :test as undef..


my $sql4 =3D qq(
CREATE GLOBAL TEMPORARY TABLE "ip_table"
(
nelocn VARCHAR2(10),
netype VARCHAR2(10),
neindex VARCHAR2(10)
)ON COMMIT PRESERVE ROWS;
DECLARE
ip VARCHAR2(50):=3D :ipaddress;
BEGIN
INSERT INTO ip_table (nelocn, netype, neindex)
select equp_locn_ttname ,equp_equt_abbreviation, equp_index
from equipment
where equp_ipaddress =3D ip;

OPEN :test FOR
SELECT nelocn
FROM ip_table;

END;
);

$sth =3D $dbh->prepare($sql4);
my $sth_cursor;
$sth->bind_param(":ipaddress",$ip);
$sth->bind_param_inout(':test', \$sth_cursor, 0, {ora_type =3D> ORA_RSET =
});
$sth->execute();

The error is as follows

DBD::Oracle::st bind_param failed: ORA-01036: illegal variable name/numbe=
r (DBD
ERROR: OCIBindByName) [for Statement "
CREATE GLOBAL TEMPORARY TABLE "ip_table"
(
nelocn VARCHAR2(10),
netype VARCHAR2(10),
neindex VARCHAR2(10)
)ON COMMIT PRESERVE ROWS;
DECLARE
ip VARCHAR2(50):=3D :ipaddress;
BEGIN
INSERT INTO ip_table (nelocn, netype, neindex)
select equp_locn_ttname ,equp_equt_abbreviation, equp_index
from equipment
where equp_ipaddress =3D ip;

OPEN :test FOR
SELECT nelocn
FROM ip_table;

END;
" with ParamValues: :ipaddress=3D'10.255.4.220', :test=3Dundef] at sqlplu=
stest.pl
line 177.