[CDBI] Sequences in Class::DBI?

Rod McChesney rod.mcchesney at gmail.com
Thu Apr 27 19:20:48 BST 2006


> __PACKAGE__->set_sql('Nextval', <<NEXTVAL);
> SELECT ORDER_SEQ.NEXTVAL from DUAL
> NEXTVAL

Note that you can also do this generically for Oracle in a your CDBI base class:

__PACKAGE__->set_sql(Nextval => 'SELECT %s.NEXTVAL from DUAL');

I got that from the Oracle sequence plugin.

Rod

On 4/26/06, leif.eriksen at hpa.com.au <leif.eriksen at hpa.com.au> wrote:
> Here's a snippet of how we do it for our Oracle system
>
> package Orders;
>
> use base qw(OurSystem::DBI);
> ...
> __PACKAGE__->sequence(qw(ORDER_SEQ));
>
> __PACKAGE__->set_sql('Nextval', <<NEXTVAL);
> SELECT ORDER_SEQ.NEXTVAL from DUAL
> NEXTVAL
>
>
> Obviously the postscript way of selecting the next value from a sequence
> will vary, bit you just need to stick that in the set_sql for 'NextVal'
>
> Leif




More information about the ClassDBI mailing list