John Lawler wrote:
> In MSSQL, I can write a stored procedure that 
> does something like this:
> 
> CREATE PROCEDURE test(
>   @lookup char(50))
> WITH ENCRYPTION AS BEGIN
> 
> -- ... a bunch of code to do some lookup, and then ...
> 
> SELECT
>    @Result1 AS Result1,
>    @Result2 AS Result2,
>    @Result3 AS Result3,
>    @Result4 AS Result4

Not sure if this a function like this does everything you may want, but it may 
work for you.
Disclaimer: I have not actually used the proc with the "As" for the column 
names,
but I'd expect it "should" work.

CREATE FUNCTION "getlogdata"("int4", "int4", "int4", "int4") RETURNS 
"refcursor" AS '
 DECLARE curs refcursor; 
BEGIN
  OPEN curs FOR 
  SELECT logdata.datavalue As Result1,logdata.timestamp As Result2
                 from logdata
                where logfielddatatype = $1
                 and graphtargetlog = $2
                 and (timestamp >=  $3 OR $3 = 0)
                 and (timestamp <=   $4 OR $4 = 0)
                order by timestamp;
 RETURN curs;
END;
' LANGUAGE 'plpgsql';

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to