0

I have a postgresql function like

create or replace function getalltypes(name character varying(100))
returns  setof docs as $BODY$ 

begin
perform c.contenttypename from conttype c;

end;
$BODY$  LANGUAGE PLPGSQL;

docs is a type I have created

create type docs as (contenttypename character varying(100))

on

select getalltypes('') 

No result is getting displayed. Can anyone please help?

2
  • 1
    you probably want to change perform c.contenttypename from conttype c; to return query c.contenttypename from conttype c; ?.. Commented Nov 16, 2016 at 11:18
  • @VaoTsun - 'return query c.contenttypename from conttype c;' is showing an error at 'c'. I changed to 'return query select c.contenttypename from conttype c;' Then it worked. Thank you Commented Nov 16, 2016 at 12:25

1 Answer 1

1

You don't have any return statement. This is why you see no result. PERFORM is used to evaluate the query and DISCARD the result This is why you should change perform c.contenttypename from conttype c; to smth like return query select c.contenttypename from conttype c;.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.