Download CS 342 Fall 2014 Database Project
Transcript
69
BEGIN
Execution_section
Return return_variable;
EXCEPTION
exception section
Return return_variable;
END;
Stored Function in Trans-SQL:
CREATE FUNCTION [ schema_name. ] function_name
( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type
[ = default ] [ READONLY ] }
[ ,...n ]
]
)
RETURNS return_data_type
[ WITH <function_option> [ ,...n ] ]
[ AS ]
BEGIN
function_body
RETURN scalar_expression
END
[;]
Stored Function in PL/SQL vs. Trans-SQL syntax:
In the Trans-SQL syntax, one must provide the name of the schema before the
function name. Also the Trans-SQL does not provide us with the “OR REPLACE”
command. PL/SQL also has a place for the exception that will print out an error
whenever an exception is fired.
Package: