DBD::Oracle doesn't currently talk DATE, so a date string is normally passed
as a VARCHAR.  Use TO_DATE() to convert the string to a DATE:

   # $dbh -> {RaiseError} =1; # Alternative to 'or die's
   my $sth = $dbh -> prepare(
      "UPDATE emp SET hiredate = TO_DATE( ?, 'YYYY-MM-DD' ) WHERE empno =
?" )
      or die "Prepare failed, $DBI::errstr";
   $sth -> execute( $date, $empno ) or die "Execute failed, $DBI::errstr";
   # . . .
--
Mac :})
** I normally forward private database questions to the DBI mail lists. **
Give a hobbit a fish and he'll eat fish for a day.
Give a hobbit a ring and he'll eat fish for an age.
----- Original Message -----
From: "John K. Lien" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 09, 2001 10:07 AM
Subject: binding oracle date expressions


> I'm on Oracle 8.1.6, Solaris 2.8, DBI v10.32, DBD:Oracle v1.8.
>
> How can I bind an Oracle date expression?
>
> I'd like to turn something like this:
> $statement = "UPDATE emp SET hiredate = sysdate WHERE empno = ?";
>
> into something like this:
> $statement = "UPDATE emp SET hiredate = ? WHERE empno = ?";
>
> I can bind numbers and string just fine.  But I can't figure out the
> dates.


Reply via email to