RE: temporary table "disapears"



Actually I tried this against SQL 2000, DBI 1.53 and DBD::ODBC 1.13...

You should be getting 2 errors, the same error from both prepares. In
other words, #foo isn't being treated as a proper table name.
Naturally, these statements work fine if you just use foo (which isn't
temp).

However, #foo should represent a "global temp" table, and this is not
being accepted as a valid name. Not sure why.

But ##foo works fine, and the table does persist across executes while
the $dbh connection is open. With 2 #'s, it's a "local temp" table
which means it's not visible to other sessions. If that's OK, perhaps
you can use that instead.



-----Original Message-----
From: Andon Tschauschev [mailto:atschauschev@xxxxxxxxx]
Sent: Wednesday, May 09, 2007 8:31 AM
To: dbi-users@xxxxxxxx
Subject: temporary table "disapears"

Hello,

I am using DBI 1.51 and DBD::ODBC 1.13, connecting to MSSQL2005.

Executing following statements:
$sth = $dbh->prepare('create table #foo (a int not null)');
$sth->execute(); $sth = $dbh->prepare('insert into #foo values (1)');
$sth->execute();

generate an error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name
'#foo'.

So, the temporary table "disapears".... (I tested it on Sybase, using
DBD::Sybase, too, there is no an error). Since the two statements are
dynamically created (between come other statements), I cannot execute in
one batch $sth = $dbh->prepare('create table #foo (a int not null)
insert into #foo values (1)); $sth->execute();

at once...

How can I avoid this problem?

Regards!

Andon


---------------------------------
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.
.



Relevant Pages

  • DBD::Oracle eats all my memory when using bind_param_inout_array()
    ... Today I installed DBD::Oracle 1.21 and DBI 1.605 to run with oracle instant ... my test program resulted in an "Out of Memory" error. ... print "Dropping test objects..."; ... INSERT INTO foo ...
    (perl.dbi.users)
  • Re: DBD::Oracle eats all my memory when using bind_param_inout_array()
    ... Today I installed DBD::Oracle 1.21 and DBI 1.605 to run with oracle instant ... my test program resulted in an "Out of Memory" error. ... print "Dropping test objects..."; ... INSERT INTO foo ...
    (perl.dbi.users)
  • Re: setuid
    ... > executes with root privileges since it's chmodded 4710. ... > members of a certain group run FOO, ...
    (comp.os.linux.misc)
  • temporary table "disapears"
    ... I am using DBI 1.51 and DBD::ODBC 1.13, connecting to MSSQL2005. ... Executing following statements: ... insert into #foo values ); ...
    (perl.dbi.users)
  • Re: "Compile time" checking?
    ... > Pychecker gets hung up on raw_input... ... it actually executes code ... def foo(): ...
    (comp.lang.python)