Search Postgresql Archives

Re: FUNCTION returns SETOF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rafal Pietrak <rafal@xxxxxxxxxxxxxxxxxx> writes:
> CREATE FUNCTION new_user (text,text) RETURNS SETOF people AS $$ 
> 	CREATE ROLE $1 PASSWORD $2;
> 	SELECT CASE WHEN $2 is not null THEN ROW($1, null, null, null)::people
> ELSE null::ludzie END 
> $$ language sql;

> "ERROR:  function returning set of rows cannot return null value"

If you want to return no rows, then return no rows.  Something like

	SELECT ROW($1, null, null, null)::people WHERE $2 is not null;

			regards, tom lane


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux