[CDBI] Sequences in Class::DBI?

Warren Toomey wkt at tuhs.org
Thu Apr 27 01:41:32 BST 2006


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,
	Warren




More information about the ClassDBI mailing list