perloz has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use DBI; use Data::Dumper; my $dbh = DBI->connect('dbi:ODBC:DSN=SqlExpress;UID=USER;PWD=pass;Regi +onal=No;') or die "Can't connect: $!"; $dbh->{'LongReadLen'} = 40000; my $sql = 'SELECT crcp_cod_grupo, crcp_cod_prato FROM REST.dbo.CRCP_PR +ATO WHERE crcp_cod_grupo = "E"'; my $sth = $dbh->prepare($sql); $sth->execute(1, 10); while (my @row = $sth->fetchrow_array) { print "Grupo: $row[0] Prato: $row[1]\n"; } $sth->execute(12, 17); while (my $row = $sth->fetchrow_hashref) { print "Grupo: $row->{crcp_cod_grupo} Prato: $row->{crcp_cod_prato} +\n"; } $dbh->disconnect;
Hi there, I'm a newbie in Perl... this is my first attempt ever...I'm getting an error when I run the piece of code above (copied from an example somewhere on the net): DBD::ODBC::st execute failed: called with 2 bind variables when 0 are needed at query02.pl line 14. DBD::ODBC::st fetchrow_array failed: no select statement currently executing (SQ L-HY000) at query02.pl line 15. DBD::ODBC::st execute failed: called with 2 bind variables when 0 are needed at query02.pl line 19. Describe failed during DBI::st=HASH(0x1bfc3b4)->FETCH(NAME,0) at query02.pl line 20. DBD::ODBC::st fetchrow_hashref failed: no select statement currently executing ( SQL-HY000) at query02.pl line 20. Press any key to continue . . . I'm using Microsoft SQL Server Express Can anyone help me, please.. Thanks!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: execute failed: called with 2 bind variables when 0 are needed
by Corion (Patriarch) on Dec 10, 2013 at 17:25 UTC | |
|
Re: execute failed: called with 2 bind variables when 0 are needed
by PerlSufi (Friar) on Dec 10, 2013 at 17:37 UTC | |
|
Re: execute failed: called with 2 bind variables when 0 are needed
by ig (Vicar) on Dec 11, 2013 at 00:49 UTC | |
by afoken (Chancellor) on Dec 11, 2013 at 19:54 UTC | |
|
Re: execute failed: called with 2 bind variables when 0 are needed
by Random_Walk (Prior) on Dec 11, 2013 at 08:10 UTC |