Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: help with database
Thanks that did the trick.
I forgot about the max function. Why the +1? I tried it with out that and it works. My next question is what would happen if this application is used accross multiple computers at the same time? Would the correct customer_id by identified with the correct customer?
"onedbguru" <onedbguru_at_firstdbasource.com> wrote in message
news:1145390327.156831.163740_at_v46g2000cwv.googlegroups.com...
> you are selecting ALL customer_ids into :new.customer_id...
>
> not complete syntax
> create sequence newcustseq.....
>
> create or replace trigger wine_cust_trigger
> before insert on wines
> for each ro
> begin
> select newcustseq.nextval into :new.customer_id from dual;
> end ;
> /
>
> OR
>
> this very poor-man's sequence that is not very scalable due to locking
> etc..
> create or replace trigger wine_cust_trigger
> before insert on wines
> for each ro
> begin
> select max(customer_id)+1 into :new.customer_id from customer ;
> end ;
> /
>
Received on Tue Apr 18 2006 - 15:16:33 CDT