Creating A Function In SQL

Prabhukiran345
Posted by Prabhukiran345 under Sql Server category on | Points: 40 | Views : 578
The simplified syntax for the CREATE OR REPLACE PROCEDURE statement is:

CREATE [OR REPLACE]  FUNCTION function_name
[(parameter_name [IN | OUT | IN OUT] type [, ...])]
RETURN return_datatype
{IS | AS}
BEGIN
< function_body >
END [function_name];


Simple Example:
CREATE OR  REPLACE  FUNCTION Total
RETURN number IS
total number(2) := 0;
BEGIN
SELECT count(*) into total
FROM TotalEX;

RETURN total;
END;

Comments or Responses

Login to post response