2

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$

3 Answers 3

9

Use SELECT:

SELECT function_name();
Sign up to request clarification or add additional context in comments.

3 Comments

I tried that and it is giving me the error syntax error at or near "SELECT". Maybe I am butchering the function, but it is not throwing an error. I'll edit to show my code.
LANGUAGE plpsql is wrong, this should be plpgsql with an extra "g".
Query failed: ERROR: query has no destination for result data\nHINT: If you want to discard the results of a SELECT, use PERFORM instead.
0
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;

1 Comment

Welcome to SO. How does exactly this answer the question?
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.