------=_Part_24976_28098451.1207049204515
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
How about if i do this inside a procedure:
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.
2008/3/31, x asasaxax <xanaruto@[EMAIL PROTECTED]
>:
>
> can anyone do a example for me.. an explain how it works?
>
> Thanks a lot
>
>
> 2008/3/29, Berend Tober <btober@[EMAIL PROTECTED]
>:
> >
> > x asasaxax wrote:
> > > I have the following table create table product(cod serial,
> > user_cod
> > > bigint, constraint product_fk Foreign Key(user_cod) references
> > user(cod),
> > > constraint product_pk Primary Key(cod, user_cod));
> > >
> > > What i want to happend is that:
> > > user_cod cod
> > > 1 1
> > > 1 2
> > > 1 3
> > > 2 1
> > > 3 1
> > > 3 2
> > >
> > > Can serial do that? ...
> >
> > No.
> >
> > > ...what can i do to make this happen?
> >
> >
> > http://archives.postgresql.org/pgsql-general/2006-08/msg00744.php
> >
> >
> >
>
------=_Part_24976_28098451.1207049204515
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
<pre><code class=3D"sql">How about if i do this inside a
procedure:<br><br>=
SELECT setval('sequence',(SELECT max(id) FROM table)) INTO
variable=
;<br>insert into table values(variable, ..., ...); ?<br><br>Will this be
t=
ransactional? Cause, they say that setval is a command that its
transaction=
al. Using this way i<br>
don=B4t will need to use a sequence anymore. Is that
correct?<br><br><br>Th=
anks you all.<br></code></pre><br><br><div><span
class=3D"gmail_quote">2008=
/3/31, x asasaxax <<a
href=3D"mailto:xanaruto@[EMAIL PROTECTED]
">xanaruto@[EMAIL PROTECTED]
>>:</span><blockquote class=3D"gmail_quote" style=3D"border-left:
=
1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;=
">
<div>can anyone do a example for me.. an explain how it works?</div>
<div> </div>
<div>Thanks a lot<br><br> </div>
<div><span class=3D"gmail_quote">2008/3/29, Berend Tober <<a
href=3D"mai=
lto:btober@[EMAIL PROTECTED]
" target=3D"_blank" onclick=3D"return
top.js.Ope=
nExtLink(window,event,this)">btober@[EMAIL PROTECTED]
>>:</span><div><s=
pan class=3D"e" id=3D"q_11905c1685a7f398_1">
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204,
=
204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">x asasaxax
wrote:=
<br>> I have the following
table  =
; create table product(cod serial, user_cod<br>
> bigint, constraint product_fk Foreign Key(user_cod) references
user(co=
d),<br>
> constraint product_pk Primary Key(cod, user_cod));<br>><br>>
Wha=
t i want to happend is that:<br>>
user_cod =
cod<br>>
1 &n=
bsp;  =
; 1<br>>
1 &n=
bsp;  =
; 2<br>>
1 &n=
bsp;  =
; 3<br>
>
2 &nb=
sp; =
1<br>>
3 &nb=
sp; =
1<br>>
3 &nb=
sp; =
2<br>><br>> Can serial do that?
...<br><br>No.<br><br>&g=
t; ...what can i do to make this happen?<br><br><br><a
href=3D"h=
ttp://archives.postgresql.org/pgsql-general/2006-08/msg00744.php"
target=3D=
"_blank" onclick=3D"return
top.js.OpenExtLink(window,event,this)">http://ar=
chives.postgresql.org/pgsql-general/2006-08/msg00744.php</a><br>
<br><br></blockquote></span></div></div><br>
</blockquote></div><br>
------=_Part_24976_28098451.1207049204515--


|