On Fri, Feb 27, 2004 at 04:33:22PM -0500, Nathan Gray wrote:
> How excited I am about the addition of the TYPE attribute for 'bind_col'
> added in DBI 1.41.  The example in the DBI documentation is spendid:
> 
>   $sth->bind_col(1, undef, { TYPE => SQL_DATETIME });
> 
> (The ToDo file is even more exiting, but still To Do.)
> 
> I have tried this using DBD::Oracle and DBD::Pg, without success,
> however.

Just because I wave my specification wand doesn't mean that the
multitudes of drivers suddenly do my bidding! (Sadly :-)

> This is what I am trying:
> 
>   my $sth = $dbh->prepare('select sysdate my_date from dual');
>   my $date;
>   $sth->execute;
>   $sth->bind_col(1, \$date, { TYPE => DBI::SQL_DATETIME });

Could also be written as just

    $sth->bind_col(1, \$date, DBI::SQL_DATETIME);


or, is you use DBI qw(:sql_types), then just:

    $sth->bind_col(1, \$date, SQL_DATETIME);

>   my $record = $sth->fetchrow_hashref('NAME_lc');
>   print "bound => $date, key => $record->{my_date}\n";
>   $sth->finish;
> 
> Or for PosgreSQL, the query would be:
> 
>   select current_timestamp as my_date
> 
> The output is aggrivatingly not in the SQL_DATETIME format of
> 'YYYY-MM-DD HH:MM:SS'.
>
> I am using DBI 1.41, DBD::Oracle 1.15, DBD::Pg 1.32 with Perl 5.8.2
> on i386 running GNU/Linux (osname=linux, osvers=2.4.22-xfs+ti1211,
> archname=i386-linux-thread-multi), though that is hopefully not
> important, for this question.
> 
> Is there something more I should be doing?  Must the Driver modules be
> updated for this functionality to work?

Yes.

> Must I have patience?

No: Send a patches to the driver authors! Seriously.
Someone has to make it happen.

Tim.

Reply via email to