Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Primary Key wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 15133 of 17637
Post > Topic >>

Primary Key with auto increment field

by xanaruto@[EMAIL PROTECTED] ("x asasaxax") Apr 1, 2008 at 07:43 PM

------=_Part_27064_18091299.1207089816037
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I would like to increment one field, depending of the value of the
other. here=B4s an example:

id     variable
1      1
2      1
1      2
2      2

can i do that with the following commands?

SELECT setval('sequence',(SELECT max(id) FROM table)) INTO variable;
insert into table values(variable, ..., ...);  ?

Will this be transactional? Cause, they say that setval is a command
that its transactional. Using this way i

don=B4t will need to use a sequence anymore. Is that correct?


Thanks you all.

------=_Part_27064_18091299.1207089816037
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<pre><code>I would like to increment one field, depending of the value of
t=
he other. here=B4s an example:<br><br>id     variable<br>1      1<br>2    
=
 1 <br>1      2  <br>2      2<br><br>can i do that with the following
comma=
nds?<br>
<br>SELECT setval(&#39;sequence&#39;,(SELECT max(id) FROM table)) INTO
vari=
able;<br>insert into table values(variable, ..., ...);  ?<br><br>Will this
=
be transactional? Cause, they say that setval is a command that its
transac=
tional. Using this way i<br>
<br>don=B4t will need to use a sequence anymore. Is that
correct?<br><br><b=
r>Thanks you all.<br></code></pre>

------=_Part_27064_18091299.1207089816037--
 




 2 Posts in Topic:
Primary Key with auto increment field
xanaruto@[EMAIL PROTECTED  2008-04-01 19:43:36 
Re: Primary Key with auto increment field
craig@[EMAIL PROTECTED]   2008-04-02 11:49:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 7:07:03 CST 2008.