On Tue, Sep 14, 2004 at 10:47:27AM -0000, Jbari Mohamed Said wrote:
>    Hello,
>     i have select statement in the format:
>     
>     select record1 from table where record2 in ('122','134')
>     
>     The problem is i don't know in fact the number passed to 'in' in the select 
> below so when i call
>    'execute' from PERL/DBI module like this:
>     
>       $sth = $dbh->prepare(q{select record1 from table where record2 in ?});
>      $sth->execute(@tab) || die "[2] Cannot execute: $DBI:errstr";
>     
>     where @tab may contain 3 or 5 or 10 values depending on a previous result.
>     
>     I have the following error:
>     
>     "execute called with 2 bind variables when 1 are needed at test_exceldb2.pl line 
> 42." when
>    @tab contains 2 elements for example.
>     
>     Any help will be great

You can help yourself by reading the DBI docs, where it says:

: Also, placeholders can only represent single scalar values.
: For example, the following
: statement won't work as expected for more than one value:
: 
:  "SELECT name, age FROM people WHERE name IN (?)"    # wrong
:  "SELECT name, age FROM people WHERE name IN (?,?)"  # two names

Tim.

Reply via email to