On 04/01/11 17:15, David McMath wrote:
Dear List,

Hi David,

I quick reply now without taking a look into the details of the implementation to prevent that I forget you (I'm currently busy
with other tasks ...).

The short version of my question is: Using DBD::DBM, is there a simple
way to tell whether a table exists? (Other than just trying to query it
and handling failure.)

I've tried "$dbh->{'dbm_tables'}" which seemed promising, except that
it's always empty until I actually execute a query.

That's true, the attribute dbm_tables contains only those tables which
had been "touched" in this session.

I've tried "$dbh->func('list_tables')" but that just lists all the files
in the directory. I'd rather not use that because I'd rather not have to
remember how the particular DBM handles extensions.

This shouldn't happen with a proper configured DBD::DBM session. If I
forgot to dig deeper here within next 4 business days, please feel free
to remind me.

You should include the version numbers of DBI and SQL::Statement
you use in your environment and they should better match the latest
released versions ;)
Further, you should add the OS(s) you're using (just to be sure).

The longer version of the question, with the rest of the story, is below.

Thanks for any advice,

dave

--

I have a little application that tracks state of tickets. I wrote a
proof-of-concept using DBI and DBD::SQLite. A colleague suggested I try
a different backing store, like BerkeleyDB or GDBM. "No problem," said
I, "I'll just switch to DBD::DBM."

Of course, I had cheated. In the SQLite version, I had the statement

CREATE TABLE IF NOT EXISTS tickets (...)

at the very beginning. For the DBM version, I have to remove the "IF NOT
EXISTS" phrase. The code "works", but its output is peppered with
warnings like


DBD::DBM::st execute failed: Cannot CREATE './tickets.pag' because it
already exists at
/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/DBD/DBM.pm
line 338.

Those are just warnings and everything else seems to work. At least with
SDBM.

When you're able to create a small test case to demonstrate it, you would
save me some work. This seems to be a bug, because "CREATE TABLE IF NOT EXISTS ..." should work fine without noise.

Best regards,
Jens

Reply via email to