Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
fa9eb315
Commit
fa9eb315
authored
Oct 26, 2007
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add plpgsql doc example of RETURN NEXT.
Ulrich Kroener
parent
48c16e14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
doc/src/sgml/plpgsql.sgml
doc/src/sgml/plpgsql.sgml
+28
-7
No files found.
doc/src/sgml/plpgsql.sgml
View file @
fa9eb315
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.11
6 2007/07/25 04:19:08 neilc
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.11
7 2007/10/26 01:11:09 momjian
Exp $ -->
<chapter id="plpgsql">
<title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title>
...
...
@@ -1411,16 +1411,37 @@ RETURN QUERY <replaceable>query</replaceable>;
</para>
<para>
Functions that use <command>RETURN NEXT</command> or
<command>RETURN QUERY</command> should be called in the
following fashion:
Here is an example of a function using <command>RETURN
NEXT</command>:
<programlisting>
SELECT * FROM some_func();
CREATE TABLE foo (fooid INT, foosubid INT, fooname TEXT);
INSERT INTO foo VALUES (1, 2, 'three');
INSERT INTO foo VALUES (4, 5, 'six');
CREATE OR REPLACE FUNCTION getAllFoo() RETURNS SETOF foo AS
$BODY$
DECLARE
r foo%rowtype;
BEGIN
FOR r IN SELECT * FROM foo
WHERE fooid > 0
LOOP
-- can do some processing here
RETURN NEXT r; -- return next row of SELECT
END LOOP;
RETURN;
END
$BODY$
LANGUAGE 'plpgsql' ;
SELECT * FROM getallfoo();
</programlisting>
That is, the function must be used as a table source in a
<literal>FROM</literal> clause.
Note that functions using <command>RETURN NEXT</command> or
<command>RETURN QUERY</command> must be called as a table source in
a <literal>FROM</literal> clause.
</para>
<note>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment