INSERT INTO foo VALUES (1, 2, 'three');
INSERT INTO foo VALUES (4, 5, 'six');
-CREATE OR REPLACE FUNCTION getAllFoo() RETURNS SETOF foo AS
+CREATE OR REPLACE FUNCTION get_all_foo() RETURNS SETOF foo AS
$BODY$
DECLARE
r foo%rowtype;
BEGIN
- FOR r IN SELECT * FROM foo
- WHERE fooid > 0
+ FOR r IN
+ SELECT * FROM foo WHERE fooid > 0
LOOP
-- can do some processing here
RETURN NEXT r; -- return current row of SELECT
$BODY$
LANGUAGE plpgsql;
-SELECT * FROM getallfoo();
+SELECT * FROM get_all_foo();
</programlisting>
</para>