|
Posted by Jens Thoms Toerring on May 8, 2008, 1:12 pm
Please log in for more thread options
ambarish.mitra@gmail.com wrote:
> Using the DBI module, I have connected to a CSV file, and am trying to
> execute SQL queries on the CSV file. I am stuck when there is a space
> in the field name and I cannot proceed.
> The CSV file col heading:
> "Attribute","Display Name","Semantic Type","Display Type". (ie, space
> in the heading)
> I am trying to "prepare" only those lines for which 'Display Type' is
> given.
> The error line is given:
> my $sth = $dbh->prepare("select * from report where [Display Type]
> =MultiLineText");
> SQL ERROR: Bad table or column name '[Display Type]' has chars not
> alphanumeric or underscore!
> SQL ERROR: Couldn't find predicate!
> I have tried some googling and also tried multiple combination of
> brackets/qoutes/escapes with a hope that one of them will work, but
> without luck.
> Question: What is the way to fire this command in PERL where the field
> name (and value as well) can have spaces?
I guess you're out of luck. While the documentation of DBI::CVS only
explicitely says that table names can't contain spaces (due to SQL
not allowing any) if I remember correctly also spaces in column
names aren't allowed in SQL. Thus I wouldn't expect DBI to accept
them even with some kinds of quotation/escape characters (which
probably would have an extra meaning in an SQL statement).
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
|