[Dbix-class] info Oracle: executing sql code for sequences or lock

Jess Robinson castaway at desert-island.demon.co.uk
Fri Jan 19 09:24:01 GMT 2007


Hi Igor,

On Thu, 18 Jan 2007, Igor Longagnani wrote:

> Hi Jess,
> thanks for your precious information, but still ican't figure out how to
> do this even if the big picture is clear:
>
>>
>> No, if you just make sure you have the primary key set to
>> "is_auto_increment" in the add_columns, then copy will automatically
>> empty that field for you, and it should work just the same as when you
>> use ->create. (If that works, I assuming you are using triggers and
>> sequences?)
>>
>> Jess
> 1) what do you mean by "empty that field for me" ...?  you mean that
> DBIx recognizes the "is_auto_increment" attribute so leaving to the
> programmer the responsiblity of producing those values?

I mean that copy will set the value of the field to a null value, so that, 
just like a normal initial insert, your database should automagically fill 
in the new next sequence value for you. (Assuming thats what your create 
currently does). Thats the opposite of what you suggested, 
"is_auto_increment" lets DBIx::Class know that your database (or triggers 
in your database) will fill that field.

> 2) the primary key is multifield and ... I could , but no i don't think
> triggers are being used ON BEFORE INSERT to call any sequence, at present
> what would you suggest?

Hmm, without worrying about copying or updating, start from a simple 
beginning. What do you do to create a new object/row in this table?

$schema->resultset('Tabname')->create({ center => 'foo',
                                         altno => \'(select max(altno)+1 
from tabname where center='foo')',
                                         codpat => undef });

??

DBIx::Class's PK::Auto assumes that your database will fill sequence 
values for you. If you don't have a database trigger to do that, I suggest 
you try PK::Sequence, which is in the mailing list somewhere..

Jess

> I do re-post here the rules for the multi field primary key:
>
>    I have some table, lets say TABNAME  (n.b. =$table in the Perl
> excerpt),
>    with a multifield primary-key (CENTER,ALTNO,CODPAT):
>
>    Rules for subkeys are:
>
>    CENTER doesnt change
>    ALTNOis max(ALTNO) where CENTER = <current CENTER  value>
>    CODPAT s taken form a sequence
>
> thanks again for your fast and detailed help.
>
> Igor
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>
>



More information about the Dbix-class mailing list