Hi all.

I am new to postgres, so I am still learning the basics.

In Sequel Server, one can set up a function to return a table eg:

 

CREATE FUNCTION [dbo].[AuthCodes] (@CLIENTID INT) 

RETURNS @AuthCodes TABLE

(

            [ID] INT,

            AUTHCODE VARCHAR(100),

            ISSUEDATE DATETIME,

            ISSUEDBY VARCHAR(100),

            RECIPIENT VARCHAR(100),

            EMAILID VARCHAR(100)   

)

 

and then use select into or insert to populate the table.

I am really battling to figure out how to do the same in a postgres function.

It seems like one would have to create a user defined type (myType for eg), and then set the return type of the function to be a set of myType, but I can’t seem to make it work. I am guessing that I am on the wrong track…does anyone have any suggestions, or examples I could follow?