bind_param question



The following code works just fine:

$sth = $dbh->prepare(qq(select count(*) from discounts where min_value
< ?));
$sth->bind_param( 1, 5, SQL_INTEGER);
$sth->execute();

The actual query my application uses is much longer and the rest of the
values in the where clause are varchar's.

Is there a way to assign the data type by column, then doing the execute
with the value?

Something like this:

$sth = $dbh->prepare(qq(select count(*) from discounts where min_value
< ?));
$sth->bind_param(1, SQL_INTEGER);
$sth->execute(5);

This would help too if the execute is in a loop.

like this...

$sth = $dbh->prepare(qq(select count(*) from discounts where min_value
< ? and code=?));
$sth->bind_param(1, SQL_INTEGER);

foreach (@( $myArrayHash) ){
$sth->execute($myArrayHash{'min'},$myArrayHash{'code'});
....
}


Any thoughts?



Relevant Pages

  • RE: selecting a value based on a date
    ... I still get the message "you tried to execute a query that does not include ... SO i tried replacing the having clause by the WHERE clause in the Waitdays ... chart pertaining to that dive was received. ...
    (microsoft.public.access.queries)
  • Re: query efficiency
    ... In general, the fewer phrases in the WHERE clause, the faster the query will ... execute. ... > to search for grandfathers. ...
    (microsoft.public.access.queries)
  • Re: counting records in select query
    ... You can execute a SELECT COUNTwith the appropriate WHERE clause to ... This means it will cost nearly twice as much as executing the query ... For simple queries counting is fine--but it just ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Query occasionally returning empty results in 8i
    ... clause, second a query with where clause (executed ... Misses in library cache during parse: ... Misses in library cache during execute: ...
    (comp.databases.oracle.server)
  • Re: Creatinig a database to update in alphabetical order
    ... Use a query with the ... appropriate ORDER BY clause to display the data, ... Prev by Date: ...
    (microsoft.public.access.gettingstarted)