On Mon, 26 Nov 2012 11:49:49 -0500, "Scott R. Godin" <scot...@mhg2.com>
wrote:

> 
> On 11/25/2012 04:16 AM, Jens Rehsack wrote:
> > On 25.11.12 10:00, H.Merijn Brand wrote:
> >> On Fri, 23 Nov 2012 17:43:50 -0500, "Scott R. Godin" <scot...@mhg2.com>
> >> wrote:
> >>
> >>> I've run into an issue where I need both col_names set and
> >>> skip_first_line still set to TRUE, because of malformed colnames in the
> >>> original dumpfiles that conflict with SQL Reserved Words (such as
> >>> 'key')
> >>> that I am unable to find any other acceptable workaround short of
> >>
> >> Why not automate the hacking using Text::CSV_XS and rewrite the header
> >> before using DBD::CSV?
> >
> > Or simply quote the column names in your SQL statement?
> 
> I tried various quoting mechanisms up to and including attempting to use
> backticks, but all result in errors of one kind or another

Can you attach the first 4 lines of your csv datafile?

> $dbh->prepare(q{Select 'key', PHM_ID, DAW_CD, GENBRND_CD from clms limit
> 10})
> results in every record having the literal value "key" for the column `key`
> same if I try select 'key' as PKEY
> 
> if I switch to double-quotes rather than single quotes around "key" in
> the above, I get the following error:
> Execution ERROR: No such column '"key"' called from clms_test.pl at 23.
> 
> I'll look into playing with Text::CSV_XS, and see what I can come up with.
> 
> I still think it would be easier if skip_first_line were not presumed
> (forced to) false if col_names is set, but rather presumed false only if
> not set explicitly true.

We agree, investigating what is actually required (and should be
documented)

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.17   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Reply via email to