[CDBI] Sequences in Class::DBI?

leif.eriksen at hpa.com.au leif.eriksen at hpa.com.au
Thu Apr 27 04:09:25 BST 2006

Here's a snippet of how we do it for our Oracle system

package Orders;

use base qw(OurSystem::DBI);

__PACKAGE__->set_sql('Nextval', <<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'

-----Original Message-----
From: wkt at tuhs.org [mailto:wkt at tuhs.org] 
Sent: Thursday, 27 April 2006 10:42 AM
To: classdbi at lists.digitalcraftsmen.net
Subject: [CDBI] Sequences in Class::DBI?

Hi, I'm rewriting a reasonably big project to use Class::DBI instead of
DBIx::Abstract. How can one get access to sequences in Class::DBI? Given
a sequence in Postgresql, I want to access the current value and the
next value. With DBIx::Abstract I can do:

sub Get_NextSequence($)
  my ($result)= Clone()->select_one_to_array( "nextval('" . $_[0] ."')"
  return($result || 0);

sub Get_CurrSequence($)
  my ($result)= Clone()->select_one_to_array( "currval('" . $_[0] ."')"
  return($result || 0);

How can I do the same in Class::DBI? I assume that I will need a
separate class for each sequence, but given a sequence called 'daynum',
how do I write the class?

Many thanks,

ClassDBI mailing list
ClassDBI at lists.digitalcraftsmen.net
The contents of this e-mail and its attachments are confidential and intended
solely for the use of the individual or entity to whom they are addressed.  If
you received this e-mail in error, please notify the HPA Postmaster, postmaster at hpa.com.au,
then delete  the e-mail.
This footnote also confirms that this e-mail message has been swept for the
presence of computer viruses by Ironport. Before opening or using any
attachments, check them for viruses and defects.
Our liability is limited to resupplying any affected attachments.
HPA collects personal information to provide and market our services. For more
information about use, disclosure and access see our Privacy Policy at

More information about the ClassDBI mailing list