Re: Postgres Function in plpgsql, returning null results to Postfix

This is a discussion on Re: Postgres Function in plpgsql, returning null results to Postfix within the mailing.postfix.users forums, part of the Mail Servers and Related category; On Tuesday 24 May 2005 9:04 am, Simon Waters wrote: > What is the correct syntax for returning a ...


Go Back   Usenet Forums > Mail Servers and Related > mailing.postfix.users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2005
Steve Crawford
 
Posts: n/a
Default Re: Postgres Function in plpgsql, returning null results to Postfix

On Tuesday 24 May 2005 9:04 am, Simon Waters wrote:
> What is the correct syntax for returning a null or empty result?
>
> i.e. "RETURN NULL;" creates a one row, one column, result by the
> looks of it, which Postfix doesn't like.
>
> I'm currently doing the virtual_alias_map but I assume the answer
> is generic?
>
> Otherwise plpgsql functions seem a very easy and natural way to
> handle our more complex features.


This is a PostgreSQL question, not a Postfix question. "select null"
will return a single row, single column result with a null value. So
does "select some_function_which_returns_null()".

I don't know what problem you are trying to solve, but it sounds like
you need to read up on set returning functions in PostgreSQL.

The following snippet is from
http://www.varlena.com/varlena/GeneralBits/26.html and shows how you
can create a function that returns 0 or more rows of records.

CREATE OR REPLACE FUNCTION getemployeedid ( integer )
RETURNS SETOF integer as '
DECLARE
myrow RECORD;
retval integer;
BEGIN
FOR myrow IN SELECT * FROM employee where salary >= $1 LOOP
RETURN NEXT myrow.departmentid;
END LOOP;
RETURN;
END;
' language 'plpgsql';

Warning: set returning functions are find for small recordsets but
scale poorly for large return values as the full return set must be
assembled in memory before the function returns.

Cheers,
Steve
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:09 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0