Search Postgresql Archives

Re: How to return an array of values from a function?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/15/2011 09:13 AM, Siva Palanisamy wrote:

Hi All,

 

I wish to return an array of values. Assume, I have a table called contacts. I want to display all the names available from a column in the UI. Hence I need to return that column as an array of values. Please correct me if there is any other solution exist.

 

Here is the code, I’m trying to execute:

 

CREATE OR REPLACE FUNCTION get_all_names()

RETURNS TEXT[] AS '

DECLARE

group_data TEXT[];

BEGIN

Try

--SELECT display_name INTO group_data FROM contacts;

select array(select display_name from contacts) into group_data;

RETURN group_data;

END;

'LANGUAGE 'plpgsql';

 

During compilation, I got the below error:

 

ERROR:  array value must start with "{" or dimension information

CONTEXT:  PL/pgSQL function "get_all_ names " line 4 at SQL statement

 

Regards,

Siva.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux