Code Blocks
CREATE FUNCTION identifier (arguments) RETURNS type AS '
DECLARE
declaration;
[...]
BEGIN
statement;
[...]
END;
' LANGUAGE 'plpgsql';
Comments
-- This will be interpreted as a single-line comment.
/*
* This is a
* block
* comment.
*/
Expressions
CREATE FUNCTION a_function () RETURNS int4 AS '
DECLARE
an_integer int4;
BEGIN
an_integer := 10 * 10;
return an_integer;
END;
' LANGUAGE 'plpgsql';
Variables
Data types;
- boolean
- text
- char
- integer
- double precision
- date
- time
variable_name data_type [ := value ];
CREATE FUNCTION identifier (arguments) RETURNS type AS '
DECLARE
-- Declare an integer.
subject_id INTEGER;
-- Declare a variable length character.
book_title VARCHAR(10);
-- Declare a floating point number.
book_price FLOAT;
BEGIN
statements
END;
' LANGUAGE 'plpgsql';
|