Your TYPE or mine?
Sometimes the data type for bind values needs to be specified
use DBI qw(:sql_types);
- to import the type constants
$sth->bind_param(1, $value, { TYPE => SQL_INTEGER });
- to specify the INTEGER type
- which can be abbreviated to:
$sth->bind_param(1, $value, SQL_INTEGER);
To just distinguish numeric versus string types, try
$sth->bind_param(1, $value+0); # bind as numeric value
$sth->bind_param(1, ”$value”); # bind as string value
- Works because perl values generally know if they are strings or numbers. So...
- Generally the +0 or ”” isn’t needed because $value has the right ‘perl type’ already