If you already have the function, I don't understand why you wouldn't want
to use it in Perl/DBI.  If you are talking about a brand new function, then
can't you just write it in Perl and call it after fetching the data?

For example :

my $sth = $dbh->prepare(q(select raw_data from my_table));
$sth->execute;
my ($raw_data, $cooked_data);
$sth->bind_columns(\($raw_data));
while ($sth->fetch) {
    $cooked_data = my_perl_func($raw_data);
    :
}

However, if there is even a remote chance that you may want to access the
raw data from PL/SQL, then it would be best to write the function in PL/SQL
and have it live in the database.  As Ken mentioned, you can of course
define a PL/SQL function using Perl/DBI just the same as you would using
SQL*Plus or any other Oracle/SQL tool.

Regards,

Steve

> -----Original Message-----
> From: Riccardo Bonuccelli [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, 6 September 2006 7:40 PM
> To: Steve Baldwin
> Cc: [email protected]
> Subject: Re: DBI custom functions
> 
> Thanks Steve,
> 
> I agree, you can call the function this way, but then you have to be sure
> that the function is already defined in Oracle. I was wondering if there
> is
> a way to define the function with DBI..
> 
> 
> 2006/9/6, Steve Baldwin <[EMAIL PROTECTED]>:
> >
> > You should be able to simply use the function in the SQL within your
> Perl
> > script.  For example :
> >
> > my $sth = $dbh->prepare(q(
> >     SELECT  my_func(raw_data)
> >     FROM    my_table
> > ));
> >
> > etc
> >
> > If you can use the function in SQL*Plus, you can use it with Perl/DBI.
> >
> > HTH,
> >
> > Steve
> >
> > > -----Original Message-----
> > > From: Riccardo Bonuccelli [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, 6 September 2006 6:37 PM
> > > To: [email protected]
> > > Subject: DBI custom functions
> > >
> > > Hello there,
> > >
> > > I must retrieve a particular field from an Oracle DB with perl/DBI.
> This
> > > field is actually formatted as a kind of bytestring and I developed an
> > > oracle function to retrieve that field in a correct way, but as I told
> I
> > > have to connect through DBI.
> > >
> > > So the question is:
> > > Is there a way to define custom functions to be used in a dbi session?
> > >
> > > Thanks in advance.
> > >
> > > --
> > > Riccardo
> > > http://www.flickr.com/photos/askthepixel
> >
> >
> >
> 
> 
> --
> Riccardo
> http://www.flickr.com/photos/askthepixel


Reply via email to