Skip to content

Commit 360e61e

Browse files
committed
Update FAQ.
1 parent 1ebc028 commit 360e61e

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

doc/FAQ

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Frequently Asked Questions (FAQ) for PostgreSQL
33

4-
Last updated: Sat Oct 13 01:26:55 EDT 2001
4+
Last updated: Sun Oct 14 19:27:20 EDT 2001
55

66
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
77

@@ -826,10 +826,8 @@ BYTEA bytea variable-length byte array (null-safe)
826826
object with the nextval() function before inserting and then insert it
827827
explicitly. Using the example table in 4.16.1, that might look like
828828
this in Perl:
829-
$sql = "SELECT nextval('person_id_seq')";
830-
$newSerialID = ($conn->selectrow_array($sql))[0];
831-
INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal');
832-
$res = $dbh->do($sql);
829+
new_id = output of "SELECT nextval('person_id_seq')"
830+
INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal');
833831

834832
You would then also have the new value stored in $newSerialID for use
835833
in other queries (e.g., as a foreign key to the person table). Note
@@ -840,9 +838,7 @@ BYTEA bytea variable-length byte array (null-safe)
840838
Alternatively, you could retrieve the assigned SERIAL value with the
841839
currval() function after it was inserted by default, e.g.,
842840
INSERT INTO person (name) VALUES ('Blaise Pascal');
843-
$res = $conn->do($sql);
844-
$sql = "SELECT currval('person_id_seq')";
845-
$newSerialID = ($conn->selectrow_array($sql))[0];
841+
new_id = output of "SELECT currval('person_id_seq')";
846842

847843
Finally, you could use the OID returned from the INSERT statement to
848844
look up the default value, though this is probably the least portable

doc/src/FAQ/FAQ.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
alink="#0000FF">
1313
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
1414

15-
<P>Last updated: Sat Oct 13 01:26:55 EDT 2001</P>
15+
<P>Last updated: Sun Oct 14 19:27:20 EDT 2001</P>
1616

1717
<P>Current maintainer: Bruce Momjian (<A href=
1818
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
@@ -1050,10 +1050,8 @@ <H4><A name="4.16.2">4.16.2</A>) How do I get the value of a
10501050
example table in <A href="#4.16.1">4.16.1</A>, that might look like
10511051
this in Perl:</P>
10521052
<PRE>
1053-
$sql = "SELECT nextval('person_id_seq')";
1054-
$newSerialID = ($conn->selectrow_array($sql))[0];
1055-
INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal');
1056-
$res = $dbh->do($sql);
1053+
new_id = output of "SELECT nextval('person_id_seq')"
1054+
INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal');
10571055
</PRE>
10581056
You would then also have the new value stored in
10591057
<CODE>$newSerialID</CODE> for use in other queries (e.g., as a
@@ -1068,9 +1066,7 @@ <H4><A name="4.16.2">4.16.2</A>) How do I get the value of a
10681066
<I>after</I> it was inserted by default, e.g.,</P>
10691067
<PRE>
10701068
INSERT INTO person (name) VALUES ('Blaise Pascal');
1071-
$res = $conn->do($sql);
1072-
$sql = "SELECT currval('person_id_seq')";
1073-
$newSerialID = ($conn->selectrow_array($sql))[0];
1069+
new_id = output of "SELECT currval('person_id_seq')";
10741070
</PRE>
10751071
Finally, you could use the <A href="#4.17"><SMALL>OID</SMALL></A>
10761072
returned from the <SMALL>INSERT</SMALL> statement to look up the

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy