diff options
Diffstat (limited to 'doc/src/FAQ/FAQ.html')
-rw-r--r-- | doc/src/FAQ/FAQ.html | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/doc/src/FAQ/FAQ.html b/doc/src/FAQ/FAQ.html index 4329e2b5e10..90e2588b6e9 100644 --- a/doc/src/FAQ/FAQ.html +++ b/doc/src/FAQ/FAQ.html @@ -12,7 +12,7 @@ alink="#0000FF"> <H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1> - <P>Last updated: Fri Oct 12 23:37:30 EDT 2001</P> + <P>Last updated: Fri Oct 12 23:53:35 EDT 2001</P> <P>Current maintainer: Bruce Momjian (<A href= "mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR> @@ -1046,10 +1046,12 @@ BYTEA bytea variable-length byte array (null-safe) value from the sequence object with the <I>nextval()</I> function <I>before</I> inserting and then insert it explicitly. Using the example table in <A href="#4.16.1">4.16.1</A>, that might look like - this:</P> + this in Perl:</P> <PRE> - $newSerialID = nextval('person_id_seq'); + $sql = "SELECT nextval('person_id_seq')"; + $newSerialID = ($conn->selectrow_array($sql))[0]; INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal'); + $res = $dbh->do($sql); </PRE> You would then also have the new value stored in <CODE>$newSerialID</CODE> for use in other queries (e.g., as a @@ -1064,7 +1066,9 @@ BYTEA bytea variable-length byte array (null-safe) <I>after</I> it was inserted by default, e.g.,</P> <PRE> INSERT INTO person (name) VALUES ('Blaise Pascal'); - $newID = currval('person_id_seq'); + $res = $conn->do($sql); + $sql = "SELECT currval('person_id_seq')"; + $newSerialID = ($conn->selectrow_array($sql))[0]; </PRE> Finally, you could use the <A href="#4.17"><SMALL>OID</SMALL></A> returned from the <SMALL>INSERT</SMALL> statement to look up the @@ -1076,7 +1080,8 @@ BYTEA bytea variable-length byte array (null-safe) <H4><A name="4.16.3">4.16.3</A>) Don't <I>currval()</I> and <I>nextval()</I> lead to a race condition with other users?</H4> - <P>No. This is handled by the backends.</P> + <P>No. Currval() returns the current value assigned by your + backend, not by all users.</P> <H4><A name="4.17">4.17</A>) What is an <SMALL>OID</SMALL>? What is a <SMALL>TID</SMALL>?</H4> |