Pinsickle
Pinsickle

Reputation: 633

call function in postgresql

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 REPLACE 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$

Upvotes: 2

Views: 11485

Answers (3)

Yevgeniy Afanasyev
Yevgeniy Afanasyev

Reputation: 41300

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();

Upvotes: 0

Xavier
Xavier

Reputation: 1

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;

Upvotes: 0

Frank Heikens
Frank Heikens

Reputation: 126970

Use SELECT:

SELECT function_name();

Upvotes: 9

Related Questions