Received: from bush.rutgersinsurance.com (IDENT:root@rutgersinsurance.com [38.138.71.194]) by hub.org (8.10.1/8.10.1) with ESMTP id e7FI6sn86385 for ; Tue, 15 Aug 2000 14:06:54 -0400 (EDT) Received: from Adam ([10.10.10.51]) by bush.rutgersinsurance.com (8.9.3/8.9.3) with SMTP id OAA03272 for ; Tue, 15 Aug 2000 14:10:25 -0400 Message-ID: <010201c006e3$bc6d5ac0$330a0a0a@Adam> From: "Adam Lang" To: References: Subject: Re: copy from Date: Tue, 15 Aug 2000 14:07:55 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200008/118 Gotcha. Now, if I do an insert and just don't specify that field at all, it will, use the default value, correct? As long as I don't "touch" the field with anything it uses the default. Adam Lang Systems Engineer Rutgers Casualty Insurance Company ----- Original Message ----- From: "Stephan Szabo" To: "Adam Lang" Cc: Sent: Tuesday, August 15, 2000 2:00 PM Subject: Re: [SQL] copy from > > Sort of. You can give the field a default value of > nextval() which means that if you do not specify > the column in an insert, it automatically gets the default > value which should be the next value in the sequence. > Note, that not putting the column is different from inserting a > NULL into the field. > > (Example: > sszabo=# create sequence xyzseq; > CREATE > sszabo=# create table xyzseqtest ( a int default nextval('xyzseq'), b > int); > CREATE > sszabo=# insert into xyzseqtest (b) values (2); > INSERT 172188 1 > sszabo=# insert into xyzseqtest (b) values (3); > INSERT 172189 1 > sszabo=# select * from xyzseqtest; > a | b > ---+--- > 1 | 2 > 2 | 3 > (2 rows) > ) > > There are issues about this dealing with rules and triggers where another > row may be inserted or the default may be evaluated a second time where > you want to get the value you just inserted back, but in general it works. > > On Tue, 15 Aug 2000, Adam Lang wrote: > > > Hmmm... well, I don't think I have an "explicit" nextval. I created the > > table and then I did a create sequence broker_id; > > > > Are you implying that I can set the field to automatically create a nextval?