CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: DBI:
select statements containing ()


New User

Mar 8, 2010, 7:54 AM

Post #1 of 1 (5782 views)
select statements containing () Can't Post

Hi all,

I have a program which connects to a .csv file to read in certain columns and this all works fine apart from specific column headers. Some of the headers contain brackets i.e. myheader(moreheader) is one column name. To make my code work on these columns, I have to manually rename the headers, removing the brackets. Does anyone know how to use myheader(moreheader) in a SELECT statement without having to change the headers (and ideally without using col_names as columns are not always in the same order, but they do always have the same 'default' column names).

The correct column headers (i.e. with the brackets) are given when I run the following:

print "$sth->{NAME}[$i]\n"

But when I execute my $sth = $dbh->prepare("SELECT `myheader(moreheader)` FROM $file"); i get the following error:

DBD::CSV::db prepare failed: Unknown function '`myheader'

I have tried with and without the backquotes and have tried using underscores in place of the brackets (I read about the 'sanitizer', which reads in column headers.) All give errors and I'm really stumped!

Any help would be great,

Many thanks


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives