NAME

Role::Pg::Sequences - Client Role for handling PostgreSQL Sequences

VERSION

version 0.002

DESCRIPTION

This role handles the use of Sequences in a PostgreSQL database.

NAME

Role::Pg::Sequences

ATTRIBUTES

sequences_dbh

Role::Pg::Sequences tries to guess your dbh. If it isn't a standard dbi::db named dbh, or constructed in a dbix::class schema called schema, you have to return the dbh from _build_sequences_dbh.

sequences_schema

Should be set to the name of the database schema to hold the sequence. Default "public".

METHODS

create_sequence

 $self->create_sequence(sequence => 'my_sequence');

 Optional parameters:

 	temporary - if set, means that the sequence is temporary and will disappear when the current session is closed
	increment - the value that the sequence will be incremented by
	minvalue - the minimumn value of the sequence. Default 1
	maxvalue - the maximum value of the sequence. Default 2^63-1
	start - Which value to be the first. Default minvalue
	cache - How many sequence numbers to cache

Creates a sequence.

An optional password can be added. The user (or group) is then created with an encrypted password.

drop_sequence

$self->drop_sequence(sequence => 'my_sequence');

Drops a sequence.

sequence_exists

print "It's there" if $self->sequence_exists(sequence => 'my_sequence');

Returns true if the sequence exists.

nextval

my $sequence_value = $self->nextval(sequence => 'my_sequence');

Increments and returns the next value of the sequence

setval

$self->nextval(sequence => 'my_sequence', value => $new_value);

Returns the new value

The optional parameter is_called determines if the value is already incremented. Set this parameter to a false value
if you want the next nextval to NOT increment the value.

Sets the value of the sequence

lastval

my $sequence_value = $self-lastval;

Returns the latest value of any sequence

AUTHOR

Kaare Rasmussen <kaare@cpan.org>.

COPYRIGHT

Copyright (C) 2015, Kaare Rasmussen

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.

AUTHOR

Kaare Rasmussen <kaare at cpan dot net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Kaare Rasmussen.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.