Yes this will work for Oracle and Postgresql where sequences are used.
It won't work for SQL7, Mysql or Postgresql(using serial data type)
'cause in these cases the next id is automatically created on insert. 

Norman Widders wrote:
> 
> On Sun, 10 Dec 2000, Peter wrote:
> 
> > This technique of using the db's auto increneting attribute works fine
> > unless you want the user to see the next id, invoice no, sample no etc
>   ^^^^
> err no, the technique of using autoincrementing works just fine.
> do a select and use a temporary variable to hold the nextval before doing
> the insert using the tempvar.
> 
> select nextval('mytable_id_seq')
> 
> /Norman
> 
> Paladin Corporation Pty Ltd.  Ph:+612 9835-4782     Fax:+612 9864-0487
> Software Engineering:         c/c++/perl/sql/eiffel/pascal/haskell/php
> Powered by FreeBSD/SMP                  http://www.paladincorp.com.au/
> The  lyf  so  short,  the  craft  so  long  to  lerne     -    Chaucer
> Unix, VMS, MVS since the 80's,   FreeBSD from 2.1.6,   Linux since '94


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to