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

Here is the (correct) fix. I'll discuss with TimBo if I can submit this:

You'd have to change (in sub execute) .../DBI/DBD/SqlEngine.pm yourself for now.

unless ($sth->{sql_params_checked}++) { # bug in SQL::Statement 1.20 and below causes breakage # on all but the first call my @req_prm = $stmt->params (); my $n_req = @req_prm == 1 && ref $req_prm[0] ? $req_prm[0]->nu +m : scalar @req_prm; unless ($n_req == (my $nparm = @$params)) { my $msg = "You passed $nparm parameters where $n_req requi +red"; $sth->set_err ($DBI::stderr, $msg); return; } }

Enjoy, Have FUN! H.Merijn
  • Comment on Re: "You passed 0 parameters where 1 required" error using DBD::CSV, an INNER JOIN, and a WHERE clause
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: "You passed 0 parameters where 1 required" error using DBD::CSV, an INNER JOIN, and a WHERE clause
by planetscape (Chancellor) on Jun 22, 2011 at 16:11 UTC

    YES! This did the trick! (Well, I also needed to change the WHERE to AND when combined with INNER JOIN ... ON ... I think I read that somewhere... ;-) )

    Thanks, Tux, you ROCK!

    HTH,

    planetscape
Re^2: "You passed 0 parameters where 1 required" error using DBD::CSV, an INNER JOIN, and a WHERE clause
by planetscape (Chancellor) on Jun 29, 2011 at 04:42 UTC

    Actually, there seems to be a problem with this fix.

    If I run the code from Re: DumpArrayToExcel (for example):

    use DBI; my $dbh=DBI->connect('dbi:CSV:'); my $AoA =[ ['number','name','sex','age'], ['0','Jack','M','28'], ['1',"Marry",'F','29'] ]; $dbh->do("CREATE TABLE worksheet AS IMPORT(?)",{},$AoA); __END__

    I get the following error on Strawberry Perl (where I installed your patch), but not on Cygwin Perl, which was unchanged:

    DBD::CSV::db do failed: You passed 1 parameters where 0 required [for +Statement "CREATE TABLE worksheet AS IMPORT(?)"] at 443517.pl line 6.
    planetscape

      This quite obviously is a bug in SQL::Statement, as when I display the requireed parameters (r) and the parameters actually passed (p), I see this:

      { p => [ [ [ 'number', 'name', 'sex', 'age' ], [ 0, 'Jack', 'M', 28 ], [ 1, 'Marry', 'F', 29 ] ] ], r => [ bless ({ num => 0 }, 'SQL::Statement::Param' ) ] }

      You could disable the complete parameter count match test if the required params is a blessed SQL::Statement::Param object, but I'm afraid that is sweeping problems under the carpet.

      Update: the this statement passed by accident before my fix, as the required list of parameters consisted of only one (wrong) item: an unchecked blessed object. The number of items in the parameters passed was also just one single item: a list reference. The old test just check the lowest level where one happens to be one and the test passed.


      Enjoy, Have FUN! H.Merijn

        Thank you.

        What are the chances of getting this bug squashed in the near future? Or, what version(s) of the module(s) should I revert to?

        planetscape