On 2007-08-23 10:17:58 +0800, Ow Mun Heng wrote:
> Current method.. pseudo code.
> 
> while (1)
> {
> $from_datetime = time;
> $to_datetime = time + $time_interval;
> 
> $query = "select count(*) from table where time >= ? and time <?";
> $sth = $dbh->prepare($query) 
> $sth->execute($from_datetime, $to_datetime)
> $from_datetime = $to_datetime;
> }

Please don't post pseudo code. It is hard to say what you are doing
wrong if you don't tell us what you are actually doing. Post a
complete, minimal script which demonstrates the problem.


> 
> Results:
> 
[...]
> 2nd subsequent queries
> <- DESTROY(DBI::st=HASH(8720c4c))= undef at mssql_2_postgres_cvs.pl line
> 238
> <- DESTROY(DBI::db=HASH(8755fd0))= undef at mssql_2_postgres_cvs.pl line
> 238
> !! ERROR: -1 'called with 2 bind variables when 4 are needed' (err#0)
> <- execute('2007-08-22 18:01:00' '2007-08-22 18:02:00')= undef at
> mssql_2_postgres_cvs.pl line 238
[...]
> so... how come it says 4 bind variables are needed?

I suspect that you aren't really preparing the same statement in the
second run through the loop. Maybe you conatenated two queries, or
something like that. But since we don't know your actual code, we can
just guess. Insert a 'print "query=<$query>\n" before the prepare to
check. 

        hp

-- 
   _  | Peter J. Holzer    | If I wanted to be "academically correct",
|_|_) | Sysadmin WSR       | I'd be programming in Java.
| |   | [EMAIL PROTECTED]      | I don't, and I'm not.
__/   | http://www.hjp.at/ |   -- Jesse Erlbaum on dbi-users

Attachment: pgpHDmw8RQuzI.pgp
Description: PGP signature

Reply via email to