21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DDL statements<br />

PROCEDURE<br />

A stored procedure (SP) is a code module that can be called by the client, by another stored procedure or by a<br />

trigger. Stored procedures and triggers are written in Procedural SQL (PSQL). Most SQL statements are also<br />

available in PSQL, sometimes with restrictions or extensions. Notable exceptions are DDL and transaction<br />

control statements.<br />

Stored procedures can accept and return multiple parameters.<br />

CREATE PROCEDURE<br />

Available in: DSQL, ESQL<br />

Description: Creates a stored procedure.<br />

Syntax:<br />

CREATE PROCEDURE procname<br />

[( [, ...])]<br />

[RETURNS ( [, ...])]<br />

AS<br />

[]<br />

BEGIN<br />

[]<br />

END<br />

::= [{= | DEFAULT} value]<br />

::= <br />

::= paramname [NOT NULL] [COLLATE collation]<br />

::= sql_datatype | [TYPE OF] domain<br />

::= See PSQL::DECLARE for the exact syntax<br />

/* If sql_datatype is a string type, it may include a character set */<br />

Domains supported in parameter and variable declarations<br />

Changed in: <strong>2.1</strong><br />

Description: <strong>Firebird</strong> <strong>2.1</strong> and up support the use of domains instead of SQL datatypes when declaring input/output<br />

parameters and local variables. With the “TYPE OF” modifier only the domain's type is used, not its NOT<br />

NULL setting, CHECK constraint and/or default value.<br />

Example:<br />

create domain bool3<br />

smallint<br />

check (value is null or value in (0,1));<br />

create domain bigposnum<br />

bigint<br />

check (value >= 0);<br />

29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!