X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C6CF2D1BC62 for ; Thu, 15 Apr 2004 11:34:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62880-01 for ; Thu, 15 Apr 2004 11:34:04 -0300 (ADT) Received: from wolverine.lercnetworks.com (sabertooth.lercnetworks.com [140.99.13.90]) by svr1.postgresql.org (Postfix) with ESMTP id 8EF6DD1BB49 for ; Thu, 15 Apr 2004 11:33:59 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) (uid 510) by wolverine.lercnetworks.com with local; Thu, 15 Apr 2004 08:16:02 -0400 References: <29772.1081913447@sss.pgh.pa.us> In-Reply-To: <29772.1081913447@sss.pgh.pa.us> From: "Dennis" To: Tom Lane Cc: "postgres SQL" Subject: Re: function returning array Date: Thu, 15 Apr 2004 08:16:02 -0400 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/138 X-Sequence-Number: 17513 Tom Lane writes: > "Dennis" writes: >> I am trying to return an array from a function and don't seem to be having >> luck. > > Seems to work for me ... what PG version are you using? pg 7.4.1 I should have listed the source for the function. Here is a simplified parseString function and the foo that calls it. dennis=# create or replace function parseString (varchar, varchar) dennis-# RETURNS varchar[] AS ' dennis'# DECLARE dennis'# pParsed varchar[]; dennis'# pString ALIAS FOR $1; dennis'# pSeparator ALIAS FOR $2; dennis'# begin dennis'# dennis'# -- example simplified dennis'# pParsed[1] = ''blah''; dennis'# pParsed[2] = ''hrmmph''; dennis'# dennis'# return pParsed; dennis'# END; dennis'# ' language plpgsql; CREATE FUNCTION dennis=# dennis=# create or replace function foo() returns varchar as ' dennis'# declare dennis'# results varchar[]; dennis'# tmpv varchar; dennis'# begin dennis'# results := parseString(''asdf'',''asdf''); dennis'# tmpv := results[1]; dennis'# RAISE NOTICE '' tmpv = % '',tmpv; dennis'# return tmpv; dennis'# end' language plpgsql; CREATE FUNCTION dennis=# select foo(); NOTICE: tmpv = foo ----- (1 row) Dennis pg-user@calico-consulting.com