On Fri, Jun 08, 2001 at 11:23:07PM +0100, Tim Bunce wrote:
> For maximum perfomance I'd suggest selecting from an Oracle 'sequence'
> before you do the insert.
Done that plenty of times...
> But for minimal app code change I'd suggest a using a PL/SQL trigger
> that implements the auto increment functionality and saves the last
> value into a per-session package variable.
>
> If you, or anyone, does the latter then I'd be very interested in
> having a copy as I'll need to do something like that soon myself.
An insert trigger that sets the 'autoincrement' column from a sequence
is something that I've done before:
create or replace trigger
mytable_ai_trigger
before insert
on mytable
for each row
begin
:new.ai_column := mytable_ai_seq.nextval;
end;
/
You can then get the value just inserted by selecting sequencename.currval
(from dual, of course).
Rob
--
Rob Fugina, Systems Guy
[EMAIL PROTECTED] -- http://www.geekthing.com
My firewall filters MS Office attachments.
I'm glad we're not getting all the government we pay for...