Code Comments
Programming Forum and web based access to our favorite programming groups.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@gmail.com>
To: Lamb Joseph <joseph_lamb@yahoo.com>
Cc: dbi-users@perl.org
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@yahoo.com> 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@gmail.com> #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=Ahu06...tDypao8Wcj9tAcJ
Post Follow-up to this messageOn Wed, 7 May 2008 12:41:01 -0700 (PDT), Lamb Joseph wrote: >I will have to break apart the SQL statement with a regex and store it that way. > >Thanks for the input. More input: take a look at Ovid's article "Lexing Your Data" on perl.com, at http://www.perl.com/pub/a/2006/01/05/parsing.html which discusses using a tokenizer (lexer) to pull tokens, such as table names, out of SQL statements. -- Bart.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.