Error creating temporary tables using DBD::ODBC MSSQL

Error creating temporary tables using DBD::ODBC MSSQL

am 08.06.2007 19:42:17 von hernan.arredondo

I all,

I white the script:

#!c:/Perl/bin/perl.exe

use DBI;
use DBD::ODBC;

$dbh = DBI->connect('dbi:ODBC:DSN', 'user', 'pwd');


#$str_sql1 = '
# declare @rownum int
# SELECT @rownum = (select count(*)
# from master..sysprocesses (nolock)
# where loginame in (\'tngusu\',\'tngprod\',\'uback\'))
# if @rownum > 0
# select @@Servername + \' NOK\' as conectividad_host
# else
# select @@Servername + \' OK\' as conectividad_host
# ';


$str_sql1 = '
declare @salida varchar(109)
declare @Stop varchar(40)
declare @Largo int

set @Stop = \'Prueba CheckServer\'
set @Largo = len(rtrim(@Stop))
create table ##Tabla
(
Resultado varchar(200)
)
insert into ##Tabla exec master..Svc_CICS \'SCCCECHO\',@Stop
select
case right(rtrim(Resultado),@Largo)
when @Stop then @@Servername + \' OK\'
else @@Servername + \' NOK\'
end as Conectividad_Host
from
##Tabla

drop table ##Tabla
';

$sql1 = $dbh->prepare($str_sql1);
$sql1->execute;

while ( @row = $sql1->fetchrow_array ) {
print "@row\n";
}

Now I got the error:

DBD::ODBC::db prepare failed: [Microsoft][ODBC SQL Server Driver][SQL
Server]Invalid object name '##Tabla'. (SQL-42S02)
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not
be prepared. (SQL-42000)(DBD: st_prepare/SQLPrepare err=-1) at
C:\Varios\scripts\Perl\DBI\UA\connect.pl line 44.
Can't call method "execute" on an undefined value at
C:\Varios\scripts\Perl\DBI\UA\connect.pl line 45.


When create a normal table it works just fine, but when try to create
a temporary table (#) it fail... I try putting the flag
odbc_exec_direct => 1 in the prepare statement but now the result
don't is empty....

Any suggestions about it? or code optimizations for the sql statement?

Note: The commented sql code works fine...

Regards,

Hernan Dario A.

--
No matter how fast processors get,
software consistently finds new ways to eat up the extra speed