PostgreSQL Functions By Example
Overview
Function Basics
By Example
PostgreSQL Functions By Example
Joe Conway
joe.conway@
credativ Group
January 20, 2012
Joe Conway
SCALE10X-PGDay
Overview
Function Basics
By Example
Introduction
Uses
Varieties
Languages
What are Functions?
Full fledged SQL objects
Many other database objects are implemented with them
Fundamental part of PostgreSQL¡¯s system architecture
Created with CREATE FUNCTION
Executed through normal SQL
target-list:
SELECT myfunc(f1) FROM foo;
FROM clause:
SELECT * FROM myfunc();
WHERE clause:
SELECT * FROM foo WHERE myfunc(f1) = 42;
Joe Conway
SCALE10X-PGDay
Overview
Function Basics
By Example
Introduction
Uses
Varieties
Languages
How are they Used?
Functions
Operators
Data types
Index methods
Casts
Triggers
Aggregates
Joe Conway
SCALE10X-PGDay
Overview
Function Basics
By Example
Introduction
Uses
Varieties
Languages
What Forms Can They Take?
PostgreSQL provides four kinds of functions:
SQL
Procedural Languages
Internal
C-language
Arguments
Base, composite, or combinations
Scalar or array
Pseudo or polymorphic
VARIADIC
IN/OUT/INOUT
Return
Singleton or set (SETOF)
Base or composite type
Pseudo or polymorphic
Joe Conway
SCALE10X-PGDay
Overview
Function Basics
By Example
Introduction
Uses
Varieties
Languages
SQL Functions
Behavior
Executes an arbitrary list of SQL statements separated by
semicolons
Last statement may be INSERT, UPDATE, or DELETE with
RETURNING clause
Arguments
Referenced by function body using $n: $1 is first arg, etc. . .
If composite type, then dot notation $1.name used to access
Only used as data values, not as identifiers
Return
If singleton, first row of last query result returned, NULL on no
result
If SETOF, all rows of last query result returned, empty set on
no result
Joe Conway
SCALE10X-PGDay
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- postgresql functions by example
- sql server database coding standards and guidelines
- sql procedures triggers and user defined functions on
- 083 2011 developing user defined functions in sas a
- workingt sql smartaccess user definedfunctions
- sql server execute statement with result set clause
- chapter 5 procedures functions and triggers
- user defined financial functions for ms sql server
- views stored procedures functions and triggers
Related searches
- sas programming by example pdf
- piecewise functions step by step
- arguments by example speech ideas
- argument by example examples
- inverse functions step by step
- angular 2 by example pdf
- postgresql if not exist
- python functions example programs
- postgresql execute sql script
- postgresql execute format
- postgresql list users
- postgresql execute using