Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Sequences, last_insert_id, SQLite, and Oracle

by gaal (Parson)
on Jun 14, 2005 at 23:48 UTC ( [id://466781]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Sequences, last_insert_id, SQLite, and Oracle
in thread Sequences, last_insert_id, SQLite, and Oracle

This looks like a nice technique. A couple of questions:
  1. What's the DML for the id field?
  2. What's the SQLite equivalent? (If there is one.)
  3. Aren't Oracle sequences safe to use unlocked from within a transaction? I was under the impression that they do work that way, so I can request a sequence and then use it. Obviously slower than what you do above, but a little more straightforward. Hmmmm, is your id just that, a sequence?
Thanks!
  • Comment on Re^2: Sequences, last_insert_id, SQLite, and Oracle

Replies are listed 'Best First'.
Re^3: Sequences, last_insert_id, SQLite, and Oracle
by etcshadow (Priest) on Jun 15, 2005 at 15:42 UTC
    Yes, you can do this by accessing the sequence, and then inserting that value (explicitly), as two sequential statements in a transaction. What I was referring to was the standard oracle method of defining a sequence and using an on-insert trigger to bind the sequence to the id column of the table (so that inserts *implicitly* fetch from the sequence). For the case of the sequence used in a trigger (thus your code is not directly accessing the sequence), this is The Way. However, if you're not using triggers to pull from your sequence implicitly, then you can certainly fetch from the sequence and just use that value.
    ------------ :Wq Not an editor command: Wq

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://466781]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.