Greeting Monks. I have a conundrum. This code causes the error "You passed 0 parameters where 1 required":

#!/usr/bin/perl -w use strict; use warnings; use DBI; my $dir = '.'; my $eol = "\n"; my $sep = ','; my $dbh_match = DBI->connect ( "DBI:CSV:", undef, undef, { f_dir => $dir, f_ext => ".csv/r", csv_eol => $eol, csv_sep_char => $sep, RaiseError => 1, PrintError => 1, } ) or die "Cannot connect: " . $DBI::errstr; my $sth_match = $dbh_match->prepare ( qq| CREATE TABLE new AS SELECT file_01.Prefix, file_01.NumberRange +, file_02.Termination, file_02.Service, file_02.ChargeBand FROM file_01 INNER JOIN file_02 ON file_01.Chargeband = file_02.ChargeBand WHERE file_02.Termination LIKE '%something%' | ); $sth_match->execute or die "Cannot execute: " . $sth_match->errstr (); DBI->trace (1); $dbh_match->disconnect;

Output:

DBD::CSV::st execute failed: You passed 0 parameters where 1 required +[for State ment " CREATE TABLE new AS SELECT file_01.Prefix, file_01.NumberRange +, file_02.Termination, file_02.Service, file_02.ChargeBa +nd FROM file_01 INNER JOIN file_02 ON file_01.Chargeband = file_02.ChargeBand WHERE file_02.Termination LIKE '%something%' "] at test_DBI__CSV_read_for_PM.pl line 32. DBD::CSV::st execute failed: You passed 0 parameters where 1 required +[for State ment " CREATE TABLE new AS SELECT file_01.Prefix, file_01.NumberRange +, file_02.Termination, file_02.Service, file_02.ChargeBa +nd FROM file_01 INNER JOIN file_02 ON file_01.Chargeband = file_02.ChargeBand WHERE file_02.Termination LIKE '%something%' "] at test_DBI__CSV_read_for_PM.pl line 32.

However, change the WHERE clause to an entirely useless WHERE 1=1, and it doesn't error!

perl -V:

Summary of my perl5 (revision 5 version 10 subversion 0) configuration +: Platform: osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL_IMPL +ICIT_CONTE XT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVCRT_READFIX', optimize='-s -O2', cppflags='-DWIN32' ccversion='', gccversion='3.4.5', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long lo +ng', lseek size=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE" -L"C:\straw +berry\c\li b"' libpth=C:\strawberry\c\lib libs= -lmsvcrt -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool - +lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lm +pr -lwinmm -lversion -lodbc32 -lodbccp32 perllibs= -lmsvcrt -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspo +ol -lcomdl g32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 + -lmpr -lw inmm -lversion -lodbc32 -lodbccp32 libc=-lmsvcrt, so=dll, useshrplib=true, libperl=libperl510.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE +" -L"C:\st rawberry\c\lib"' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_ITHREADS USE_LARGE_FILES USE_PERLIO Built under MSWin32 Compiled at Apr 5 2008 10:33:57 %ENV: PERL5LIB="/lib/perl5/site_perl/5.10" @INC: /lib/perl5/site_perl/5.10 C:/strawberry/perl/lib C:/strawberry/perl/site/lib .

DBI version: 1.615

DBD::CSV version: 0.31

I've gone blind looking at this. Please, someone, lead me out of this cave!


Update: SQL::Statement version: 1.33

Update 2011-06-24: Jens Rehsack quite correctly pointed out on irc.perl.org/6667#dbi today that SQL::Statement does NOT support combining JOIN ... ON and WHERE. I had originally tried AND, but when several variations failed with the You passed 0 parameters where 1 required error, I tried experimenting with WHERE, just to see if that made a difference, and then eventually hit upon WHERE 1=1, whence the error disappeared, and I knew something was wrong. That's when I posted here, although by that time the restriction had slipped my mind. I alluded to this in these posts, but evidently did not make myself very clear at all. ;-)

HTH,

planetscape

In reply to "You passed 0 parameters where 1 required" error using DBD::CSV, an INNER JOIN, and a WHERE clause by planetscape

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.