Fw: How to Retrieve Table Name from Statement Handle



I will have to break apart the SQL statement with a regex and store it that way.

Thanks for the input.

Joseph Lamb


----- Forwarded Message ----
From: Jonathan Leffler <jonathan.leffler@xxxxxxxxx>
To: Lamb Joseph <joseph_lamb@xxxxxxxxx>
Cc: dbi-users@xxxxxxxx
Sent: Wednesday, May 7, 2008 12:22:06 PM
Subject: Re: How to Retrieve Table Name from Statement Handle

On Wed, May 7, 2008 at 10:51 AM, Lamb Joseph <joseph_lamb@xxxxxxxxx> wrote:

I am creating a simple tool that will query one table and retrieve the
data. Then this tool will turn the data into insert statements.

I was wondering if there was a way to retrieve the table name from the
statement handle?

Similar to print "SQL statement contains $sth->{NUM_OF_FIELDS} columns\n";

but like this

print "SQL statement table name is $sth->{TABLENAME} \n";



Over and above Alexander's cogent (but gentle - the SQL could have been a
lot more complex than that) rebuttal, there's another question for you:

How did you decide which table to build the 'SELECT * FROM $table' query
from?
Can't you keep tabs on the table name from that?

(Succinctly - no, you can't tell the table name from the statement handle
because, in general, there isn't a single table name to report.)

--
Jonathan Leffler <jonathan.leffler@xxxxxxxxx> #include <disclaimer.h>
Guardian of DBD::Informix - v2008.0229 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."



____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
.