[Dbix-class] Oracle Built-In Functions

Alexander Hartmaier alexander.hartmaier at t-systems.at
Tue Aug 10 08:20:34 GMT 2010


Hi Duncan,

I prefer to pass a DateTime object to the update to not tie my schema to
Oracle when not needed.
You also might trust the time on the app server(s) more than those on
the database servers.

Your date_updated column looks like you want to have it updated on every
update. If so use DBIx::Class::TimeStamp and set_on_update => 1 for this
column.

--
Best regards, Alex


Am Mittwoch, den 04.08.2010, 16:20 +0200 schrieb Duncan Garland:
> Hi Rob,
>
> Doing it in perl is a work-around not a solution. There are lots of built-in function which may need to be used.
>
> However, you and Andrey seem to be on the right lines with the reference. \'SYSDATE' works.
>
> The following also works:
>
> $v[0]->update( { date_to => \'DECODE( \'apples\', \'pears\', \'grapes\', NVL( SYSDATE, SYSDATE ) )', left_by => $c->user->get( 'id' ) } );
>
> Although SYSDATE gets truncated for some reason. It's probably OK for more sensible examples.
>
> Thanks
>
> Duncan
>
> -----Original Message-----
> From: Rob Kinyon [mailto:rob.kinyon at gmail.com]
> Sent: 04 August 2010 13:39
> To: DBIx::Class user and developer list
> Subject: Re: [Dbix-class] Oracle Built-In Functions
>
> 2010/8/4 Андрей Костенко <andrey at kostenko.name>:
> > $rs->date_updated( \‘SYSDATE’ );
> >
> > On Wed, Aug 4, 2010 at 1:25 PM, Duncan Garland
> > <Duncan.Garland at motortrak.com> wrote:
> >> Hi,
> >>
> >> I’m struggling to persuade DBIx::Class to use simple Oracle built-ins such
> >> as SYSDATE, DECODE and NVL.
> >>
> >> Eg UPDATE table1 SET date_updated = SYSDATE, destination = NVL(
> >> $destination, ‘home’ ) WHERE ... ;
> >>
> >> $rs->date_updated( ‘SYSDATE’ );
>
> $schema->resultset('table1')->search({
> ...
> })->update({
>     date_updated => \'SYSDATE',
>     destination => $destination // 'home', # Assumes Perl 5.10 or higher
> });
>
> No reason to call NVL when you're coming from Perl.
>
> Rob
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the DBIx-Class mailing list