name [ CONSTANT ]
-type> [ NOT NULL ] [ DEFAULT | :=
+type [ NOT NULL ] [ DEFAULT | :=
value ];
return [array get NEW]
' LANGUAGE 'pltcl';
-CREATE TABLE mytab (num int4, modcnt int4, desc text);
+CREATE TABLE mytab (num int4, modcnt int4, description text);
CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab
FOR EACH ROW EXECUTE PROCEDURE trigfunc_modcount('modcnt');
will print a DEBUG log message for every row of pg_class. The return value
of spi_exec is the number of rows
- affected by query as found in
+ affected by the query as found in
the global variable SPI_processed.
- spi_exec ?-count n? ?-arrayname? ?-nullsstring? query ?value-list? ?loop-body?
+ spi_exec ?-count n? ?-arrayname? ?-nullsstring? queryid ?value-list? ?loop-body?
Execute a prepared plan from spi_prepare with variable substitution.
-book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
+set PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
]>
-
+
+
PostgreSQL Documentation
-
-
-
PostgreSQL
-
- Covering v7.0 for general release
-
- The PostgreSQL Development Team
-
-
-
- Thomas
- Lockhart
- Caltech/JPL
-
-
-
-
-
-
- (last updated 2000-05-01)
-
-
-
-
PostgreSQL is Copyright © 1996-2000
- by PostgreSQL Inc.
-
-
-
-
-
-
-
-
-
-
Summary
-
- developed originally in the UC Berkeley Computer Science Department,
- pioneered many of the object-relational concepts
- now becoming available in some commercial databases.
- It provides SQL92/SQL3 language support,
- transaction integrity, and type extensibility.
- open-source descendant of this original Berkeley code.
-
-
-
+
User's Guide
- Information for users.
-
-
+
+
+ Information for Users
+
+
+
&intro;
&syntax;
&plan;
&populate;
&commands;
-
+ &datetime;
+
+ &biblio;
+
+
+
Administrator's Guide
- Installation and maintenance information.
-
-
+
+
+ Information for Administrators
+
+
+
+
- &biblio;
-
-book>
+set>
The return data type.
The output type may be specified as a base type, complex type,
- <literal>setof type>,
- or <literal>opaque>.
- The <literal>setof>
+ <option>setof type>,
+ or <option>opaque>.
+ The <option>setof>
modifier indicates that the function will return a set of items,
rather than a single item.
- <literal>iscachable>
+ <term>iscachable>
- <literal>iscachable> indicates that the function always
+ <option>iscachable> indicates that the function always
returns the same result when given the same argument values (i.e.,
it does not do database lookups or otherwise use information not
directly present in its parameter list). The optimizer uses
- <literal>iscachable> to know whether it is safe to
+ <option>iscachable> to know whether it is safe to
pre-evaluate a call of the function.
- <literal>isstrict>
+ <term>isstrict>
- <literal>isstrict> indicates that the function always
+ <option>isstrict> indicates that the function always
returns NULL whenever any of its arguments are NULL. If this
attribute is specified, the function is not executed when there
are NULL arguments; instead a NULL result is assumed automatically.
- When <literal>isstrict> is not specified, the function will
+ When <option>isstrict> is not specified, the function will
be called for NULL inputs. It is then the function author's
responsibility to check for NULLs if necessary and respond
appropriately.
-
-
Inputs
-
-
Outputs
-
-
Description
-
-
SQL92
CREATE FUNCTION tp1 (int4, float8)
-RETURNS int4
-AS ' UPDATE bank
- SET balance = bank.balance - $2
- WHERE bank.acctountno = $1;
- SELECT 1;'
+ RETURNS int4
+ AS 'UPDATE bank
+ SET balance = bank.balance - $2
+ WHERE bank.acctountno = $1;
+ SELECT 1;'
LANGUAGE 'sql';
follows:
-select TP1( 17,100.0);
+SELECT tp1( 17,100.0);
EMP, and retrieves multiple results:
-create function hobbies (EMP) returns setof HOBBIES
- as 'select HOBBIES.* from HOBBIES
- where $1.name = HOBBIES.person'
- language 'sql';
+CREATE FUNCTION hobbies (EMP) RETURNS SET OF hobbies
+ AS 'SELECT hobbies.* FROM hobbies
+ WHERE $1.name = hobbies.person'
+ LANGUAGE 'sql';
CREATE FUNCTION one()
-RETURNS int4
-AS 'SELECT 1 as RESULT;'
-LANGUAGE 'sql';
+ RETURNS int4
+ AS 'SELECT 1 as RESULT;'
+ LANGUAGE 'sql';
SELECT one() AS answer;
- +-------+
- |answer |
- +-------+
- |1 |
- +-------+
++-------+
+|answer |
++-------+
+|1 |
++-------+
CREATE FUNCTION add_em(int4, int4)
-RETURNS int4
-AS 'SELECT $1 + $2;'
-LANGUAGE 'sql';
+ RETURNS int4
+ AS 'SELECT $1 + $2;'
+ LANGUAGE 'sql';
SELECT add_em(1, 2) AS answer;
- +-------+
- |answer |
- +-------+
- |3 |
- +-------+
++-------+
+|answer |
++-------+
+|3 |
++-------+
CREATE FUNCTION double_salary(EMP)
-RETURNS int4
-AS 'SELECT $1.salary * 2 AS salary;'
-LANGUAGE 'sql';
+ RETURNS int4
+ AS 'SELECT $1.salary * 2 AS salary;'
+ LANGUAGE 'sql';
SELECT name, double_salary(EMP) AS dream
-FROM EMP
-WHERE EMP.cubicle ~= '(2,1)'::point;
-
-
- +-----+-------+
- |name | dream |
- +-----+-------+
- |Sam | 2400 |
- +-----+-------+
+ FROM EMP
+ WHERE EMP.cubicle ~= '(2,1)'::point;
+
+
++-----+-------+
+|name | dream |
++-----+-------+
+|Sam | 2400 |
++-----+-------+
FROM EMP
WHERE age(EMP) < 30;
- +----------+
- |youngster |
- +----------+
- |Sam |
- +----------+
++----------+
+|youngster |
++----------+
+|Sam |
++----------+
CREATE FUNCTION new_emp()
-RETURNS EMP
-AS ' SELECT \'None\'::text AS name,
- 1000 AS salary,
- 25 AS age,
- \'(2,2)\'::point AS cubicle'
-LANGUAGE 'sql';
+ RETURNS EMP
+ AS 'SELECT \'None\'::text AS name,
+ 1000 AS salary,
+ 25 AS age,
+ \'(2,2)\'::point AS cubicle'
+ LANGUAGE 'sql';
SELECT name(new_emp()) AS nobody;
- +-------+
- |nobody |
- +-------+
- |None |
- +-------+
++-------+
+|nobody |
++-------+
+|None |
++-------+
CREATE FUNCTION clean_EMP ()
-RETURNS int4
-AS ' DELETE FROM EMP
- WHERE EMP.salary <= 0;
- SELECT 1 AS ignore_this;'
-LANGUAGE 'sql';
+ RETURNS int4
+ AS 'DELETE FROM EMP
+ WHERE EMP.salary <= 0;
+ SELECT 1 AS ignore_this;'
+ LANGUAGE 'sql';
SELECT clean_EMP();
- +--+
- |x |
- +--+
- |1 |
- +--+
++--+
+|x |
++--+
+|1 |
++--+