In response to Tyler Hains :
> Hello,
>
>
>
> I am trying to get a function to return an integer field pulled from a
> different database using dblink. I am getting a run-time error. Here is the
> function and the error:
>
>
>
> CREATE OR REPLACE FUNCTION get_db_id()
>
> RETURNS INTEGER AS
>
> $BODY$
>
> DECLARE
>
> client_ids INTEGER[];
>
> db_id INTEGER;
>
> BEGIN
>
> SELECT INTO client_ids DISTINCT client_id FROM clients;
>
>
>
> ERROR: array value must start with "{" or dimension information
>
> SQL state: 22P02
>
> Context: PL/pgSQL function "get_db_id" line 5 at SQL statement
>
>
>
>
>
> Can anyone tell me what I?m doing wrong?
You have defined client_ids as INT[], but your select returns a SET of
integers. You can change it to :
SELECT INTO client_ids array_agg(DISTINCT client_id) FROM clients;
Regards, Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99