I made a simple function as part of my homework but for the life of me I can't figure out how to call it and test it. Can anyone tell me how?
-- Procedure
CREATE OR REPLA开发者_开发知识库CE FUNCTION addDoctor (
a INT,
b VARCHAR (20),
c VARCHAR (20)
) RETURNS VOID
LANGUAGE plpsql
AS $BODY$
BEGIN
INSERT INTO doctor
VALUES (a,b,c);
END;
$BODY$
Use SELECT:
SELECT function_name();
CREATE or REPLACE FUNCTION analyzer(character varying, character varying)
RETURNS boolean AS
$BODY$
--
begin
--
execute 'analyze '||quote_ident($1)||'.'||quote_ident($2) ;
return 1 ;
--
end ;
$BODY$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER;
if you need to call function just to check for exceptions that can occur there go perform:
PERFORM f_foo(i);
if you need a result, go select
SELECT function_name();
精彩评论