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

Igor Longagnani i.longagnani at synervis.it
Wed Jan 17 13:22:58 GMT 2007


Hi Alexander,
I am "rewriting some old script" to make it "better" ( ahahah we will
check this in the end ),
 so I am just guessing the full envrioment/project ...anyway:

I have some table, lets say TABNAME  (n.b. =$table in the Perl excerpt),
with a multifield primary-key (CENTER,ALTNO,CODPAT):
... some project specification I couldnt be made aware of, asks for
"cloning a row":

Rules for subkeys already implemented in the previous script are:

CENTER doesnt change
ALTNOis max(ALTNO) where CENTER = <current CENTER  value>
CODPAT s taken form a sequence

So, after some RTFM mumbling i thought to follow such ... "path"

                # get record data to be cloned
                my $data = $c->model($table)->find( $criteria );   
               
                # set the new key val
                my $newcriteria = $criteria;
                $newcriteria->{center}    = $new_center;
                $newcriteria->{altno}    = $new_altno;
                $newcriteria->{codpat}    = $new_codpat;   
               
                # change the key and insert the new record
                my $copy = $data->copy( $newcriteria );
               
# Do I need to call "copy->update" or "copy->insert" in the end?  ( ehm
this is a quetion in the question hehe :) )

I though i could have chaged the primary keys myself ..but, to do this,
at least 1 sub-key field has to be queried from a sequence
because of previous project decisions.

I am sure ma attempt to explain made the things wore  but i hope this
helps ...in giving a better picture.
Thanks in advance for Your help.

Igor





Hartmaier Alexander ha scritto:
> Hi Igor!
>
> I'd suggest you explain what you try to archieve first, because I *never ever* needed to fetch the nextval of a sequence by myself in any of my catalyst apps and also never to care about locking with Oracle (9 and now 10).
>
> -Alex
>
>
>   
>> -----Original Message-----
>> From: Igor Longagnani [mailto:i.longagnani at synervis.it]
>> Sent: Wednesday, January 17, 2007 10:43 AM
>> To: dbix-class at lists.rawmode.org
>> Subject: [Dbix-class] info Oracle: executing sql code for sequences or
>> lock
>>
>> Hi, once again ...
>>
>> I am using DBIX::Class into Catalyst environment and i am trying to
>> figure out a solution for 2 problems different but with common roots:
>>
>> 1 - how can i execute something like "SELECT mysequence.NEXTVAL from
>> DUAL"  ??
>>
>> 2 - how can i execute something like "lock table $tablename exclusive
>> mode nowait"  ??
>>
>> Thanks again, I am a little stuck and feel quite ignorant myself.
>> I tried some RTFM search with no real luck.
>>
>> Any clue?
>>
>> Igor
>>
>> --
>> Igor Longagnani c/o Synervis
>> -------------------------------------------------------------------
>> e-mail: i.longagnani at synervis.it             phone : +39 059 558442
>>
>> sede operativa: via Pirandello, 49/51 - 41043 Formigine (Mo) Italia
>>
>>
>> _______________________________________________
>> 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 at lists.rawmode.org/
>>     
>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
> Handelsgericht Wien, FN 79340b
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> Notice: This e-mail contains information that is confidential and may be privileged.
> If you are not the intended recipient, please notify the sender and then delete this e-mail immediately.
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
>
>
> _______________________________________________
> 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/
>
>
>   


-- 
Igor Longagnani c/o Synervis
-------------------------------------------------------------------
e-mail: i.longagnani at synervis.it             phone : +39 059 558442

sede operativa: via Pirandello, 49/51 - 41043 Formigine (Mo) Italia




More information about the Dbix-class mailing list