1. Creating PSM functions and procedures
To create a process:
CREATE PROCEDURE Name (parameter)
Partial declaration;
Process body;
To create a function:
CREATE FUNCTION Name (parameter) RETURNS type
Partial declaration;
Process body;
Parameters of the procedure: pattern-name-ternary group of type. Mode has in , out, INOUT, default in
Parameters of the function: only in.
CREATE PROCEDURE Move ( invarchar(255), invarchar( 255))UPDATE moviestarSET= newaddress WHERE = oldaddress;
2. Simple statements in PSM
2.1 Call Statement:
Call Procedure name (parameter)
Called form in the host language:EXEC SQL Call Foo (: x, 3);
As a statement in another PSM
As a SQL command sent to the basic SQL interface (no function is called): CallFoo (1, 3);
2.2 Return statement:
RETURN expression;
Can only appear in the function, the PSM return statement does not end the function, and the return value may change before the function is complete.
2.3 Local variable Declaration
DECLARE name type;
2.4 Assignment Statements
SET variable = expression;
2.5 Statement Groups
Ends with a semicolon, placed between begin and end
2.6 Statement Label
Use a name and a colon as a prefix to identify the statement.
3. Branch statements
IF condition Then
"SQL" Persistence storage module PSM