On Mar 20, 2007, at 12:48 PM, John Siracusa wrote: > On 3/20/07, Derek Watson <[EMAIL PROTECTED]> wrote: >> Is it possible to get sequence support in RDBO? I know that >> sequences are >> supported for primary key generation, but I have a few cases where >> they are >> used for non-keyed columns > > What would this support look like? How would the sequence be > specified, and how would it behave on insert, update, etc.? > >> But since next_value_in_sequence is not documented, I am worrying >> that it's >> interface may change or disappear. > > It almost certainly won't disappear and may become part of the public > API eventually. > > -John
I'll second wanting support too :) On Mar 20, 2007, at 1:11 PM, Derek Watson wrote: > I suppose my use of serial/sequence columns is too specific to > bother adding to the API, but basically > > some_seq_column => { type => 'serial', not_null => 1, sequence => > 'some_seq' }, That makes perfect sense to me. although that looks like what is in there for oracle already I'd actually like to see sequence classes Rose::DB::Object::Metadata::Sequence Which lets us map sequences to rose objects , and vice versa I'd like to be able to call my $seq= MyApp::Rose::DB::Object::Sequence1->new(); my $curval= $seq->curval; my $nextval= $seq->nextval; my $lastval = $seq->lastval; getting that to work with all dbs might be a pain though. I'll chime in with the Postgres compatibility -- if anyone wants this support too, please comment on MySQL , SQLite, Oracle, etc Postgres: Create Sequence http://www.postgresql.org/docs/8.2/interactive/sql-createsequence.html Compatibility CREATE SEQUENCE conforms to the SQL standard, with the following exceptions: The standard's AS <data type> expression is not supported. Obtaining the next value is done using the nextval() function instead of the standard's NEXT VALUE FOR expression. The OWNED BY clause is a PostgreSQL extension. Alter Sequence http://www.postgresql.org/docs/8.2/interactive/sql-altersequence.html Compatibility ALTER SEQUENCE conforms to the SQL standard, except for the OWNED BY and SET SCHEMA clauses, which are PostgreSQL extensions. Drop Sequence http://www.postgresql.org/docs/8.2/interactive/sql-dropsequence.html Compatibility DROP SEQUENCE conforms to the SQL standard, except that the standard only allows one sequence to be dropped per command, and apart from the IF EXISTS option, which is a PostgreSQL extension. Sequence Manipulation Functions http://www.postgresql.org/docs/8.2/interactive/functions-sequence.html currval(regclass) bigint Return value most recently obtained with nextval for specified sequence nextval(regclass) bigint Advance sequence and return new value setval(regclass, bigint) bigint Set sequence's current value setval(regclass, bigint, boolean) bigint Set sequence's current value and is_called flag lastval - Return the value most recently returned by nextval in the current session. This function is identical to currval, except that instead of taking the sequence name as an argument it fetches the value of the last sequence that nextval was used on in the current session. It is an error to call lastval if nextval has not yet been called in the current session. Important: To avoid blocking of concurrent transactions that obtain numbers from the same sequence, a nextval operation is never rolled back; that is, once a value has been fetched it is considered used, even if the transaction that did the nextval later aborts. This means that aborted transactions may leave unused "holes" in the sequence of assigned values. setval operations are never rolled back, either. // Jonathan Vanasco | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | SyndiClick.com | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | FindMeOn.com - The cure for Multiple Web Personality Disorder | Web Identity Management and 3D Social Networking | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | RoadSound.com - Tools For Bands, Stuff For Fans | Collaborative Online Management And Syndication Tools | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object