From: "Klay Martens" <kmartens(at)wol(dot)co(dot)za>
To: pgsql-sql(at)postgresql(dot)org
Subject:
Date: 2006-03-09 13:35:45
Message-ID: b62baae3da9741128a55d5039b7845ea@wol.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<p class="MsoNormal"><span lang="EN-ZA">Hi all.<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">I am new to postgres, so I am still
learning the basics.<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">In Sequel Server, one can set up a function
to return a table eg:<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">CREATE FUNCTION [dbo].[AuthCodes]
(@CLIENTID INT)<span style="">&nbsp; </span><o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">RETURNS @AuthCodes TABLE<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">(<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[ID]
INT,<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>AUTHCODE
VARCHAR(100),<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ISSUEDATE
DATETIME,<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ISSUEDBY
VARCHAR(100),<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>RECIPIENT
VARCHAR(100),<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>EMAILID
VARCHAR(100)<span style="">&nbsp;&nbsp;&nbsp; </span><o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">)<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">and then use select into or insert to
populate the table.<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">I am really battling to figure out how to
do the same in a postgres function.<o:p></o:p></span></p>

<p class="MsoNormal"><span lang="EN-ZA">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?<o:p></o:p></span></p>

Attachment Content-Type Size
unknown_filename text/html 2.5 KB

Responses

  • Re: at 2006-03-09 13:49:34 from Leif B. Kristensen
  • Re: at 2006-03-09 13:53:12 from A. Kretschmer
  • Re: at 2006-03-09 13:59:16 from Richard Huxton
  • Re: at 2006-03-10 12:40:45 from Markus Schaber

Browse pgsql-sql by date

  From Date Subject
Next Message Leif B. Kristensen 2006-03-09 13:49:34 Re:
Previous Message Flávio Suguimoto 2006-03-09 13:18:39 Problems with disabling triggers in Postgres 7.3.9