Re: Q: How to handle the 'date' datatype with Oraperl?

From: Phil Fielder <fimad_at_archie.lanl.gov>
Date: 1996/02/01
Message-ID: <3110CED0.7F62_at_archie.lanl.gov>#1/1


Ron Levenberg wrote:
>
> I am successfully using the Oraperl emulation (Perl5 + DBI + DBD for
> Oracle), but I've just run up against a bit of a problem: I have a
> bunch of data base fields that are of 'date' datatype. When I
> used Oraperl to do a select, they are returned as strings in the
> format '26-JAN-96', which is the default format for Oracle dates.
> I would like to convert this to a different format, mm/dd/yy or
> mm/yy. Is there anything built into Oraperl for doing this, or
> do I need to write a conversion function?
>
> Thanks - Ron Levenberg ral_at_cc.bellcore.com
one solution (in Oraperl, version 2, patch level 4) is to use the SQL To_Char function in select, update or insert strings.

Here is an example :

   $DateStr = "Select To_Char(SysDate,'dd/mm/yy') From Dual";

   $DateCsr = &ora_open($Lda,$DateStr) || &AbEnd($ora_errstr,__LINE__);

   (($Date) = &ora_fetch($DateCsr)) || &AbEnd($ora_errstr,__LINE__);

   print "Date : $Date\n";

produces :

465 :gloria:scripts% test_date.pl
Date : 01/02/96

phil

-- 
Philip Fielder     YellNet 505.665.3227     Fac. for Info.,Management,
EES-5/MS D452      FaxNet  505.667.1628     Analysis and Display
FIMAD/Los Alamos Nat. Lab	 	           
Los Alamos, NM 87545                   URL : http://ees.lanl.gov/fimad
Received on Thu Feb 01 1996 - 00:00:00 CET

Original text of this message