Error creating temporary tables using DBD::ODBC MSSQL

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 [at] rownum int
# SELECT [at] rownum = (select count(*)
# from master..sysprocesses (nolock)
# where loginame in (\'tngusu\',\'tngprod\',\'uback\'))
# if [at] rownum > 0
# select [at] [at] Servername + \' NOK\' as conectividad_host
# else
# select [at] [at] Servername + \' OK\' as conectividad_host
# ';


$str_sql1 = '
declare [at] salida varchar(109)
declare [at] Stop varchar(40)
declare [at] Largo int

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

drop table ##Tabla
';

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

while ( [at] row = $sql1->fetchrow_array ) {
print " [at] 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
hernan.arredondo [ Fr, 08 Juni 2007 19:42 ] [ ID #1733708 ]
Perl » perl.dbi.users » Error creating temporary tables using DBD::ODBC MSSQL

Vorheriges Thema: Typo in documentation
Nächstes Thema: panic: DESTROY (dbih_clearcom) in trace output