- if ( $record->{$field} =~ /^\d+(\.\d+)?$/
- && dbdef->table($table)->column($field)->type =~ /(int|(big)?serial)/i
- ) {
- $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_INTEGER } );
- }elsif ( $record->{$field} =~ /^[+-]?\d+(\.\d+)?$/
- && dbdef->table($table)->column($field)->type =~ /(numeric)/i
- ) {
- $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_FLOAT } );
- }elsif ( $record->{$field} =~ /[-+]?\d*\.?\d+([eE][-+]?\d+)?/
- && dbdef->table($table)->column($field)->type =~ /(float4)/i
- ) {
- $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_FLOAT } );
- } else {
- $sth->bind_param($bind++, $record->{$field}, { TYPE => SQL_VARCHAR } );
+
+ my $value = $record->{$field};
+ $value = $value->{'value'} if ref($value);
+ my $type = dbdef->table($table)->column($field)->type;
+
+ my $TYPE = SQL_VARCHAR;
+ if ( $type =~ /(int|(big)?serial)/i && $value =~ /^\d+(\.\d+)?$/ ) {
+ $TYPE = SQL_INTEGER;
+
+ #DBD::Pg 1.49: Cannot bind ... unknown sql_type 6
+ #} elsif ( ( $type =~ /(numeric)/i && $value =~ /^[+-]?\d+(\.\d+)?$/)
+ # || ( $type =~ /(real|float4)/i
+ # && $value =~ /[-+]?\d*\.?\d+([eE][-+]?\d+)?/
+ # )
+ # ) {
+ # $TYPE = SQL_FLOAT;
+ }
+
+ if ( $DEBUG > 2 ) {
+ no strict 'refs';
+ %TYPE = map { &{"DBI::$_"}() => $_ } @{ $DBI::EXPORT_TAGS{sql_types} }
+ unless keys %TYPE;
+ warn " bind_param $bind (for field $field), $value, TYPE $TYPE{$TYPE}\n";