Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: how to tell if ->insert succeeded in DBIx::Class?

by perl5ever (Pilgrim)
on Feb 22, 2011 at 23:40 UTC ( [id://889698]=note: print w/replies, xml ) Need Help??


in reply to Re: how to tell if ->insert succeeded in DBIx::Class?
in thread how to tell if ->insert succeeded in DBIx::Class?

This naive use of ->in_storage leads to a race condition:
sub insert_row { my ($self, $run) = @_; if ($run->in_storage) { return; } else { # race condition here $run->insert; return 1; # ??? }

Part of the problem is that the Oracle driver throws an exception for primary key violations. Catching that exception requires that I know what the exception looks like, and that leads to the Oracle-specific code.

If, for instance, $run->insert returned false if the insert failed for a unique index violation, then I could write database independent code.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://889698]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-07-24 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.