From: | "Tyler Hains" <thains(at)profitpointinc(dot)com> |
---|---|
To: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | plpgsql function help |
Date: | 2010-03-29 20:35:09 |
Message-ID: | H000006900b559c2.1269894908.mailpa.profitpointinc.com@MHS |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
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;
SELECT INTO db_id dblink('dbname=system',
'SELECT database_id FROM clients WHERE client_id =
'||client_ids[0]);
RETURN db_id;
END;
$BODY$
LANGUAGE 'plpgsql' IMMUTABLE
COST 100;
********** Error **********
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?
Thanks,
Tyler Hains
ProfitPoint, Inc.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-03-29 23:30:56 | Re: plpgsql function help |
Previous Message | Joshua Tolley | 2010-03-29 18:59:16 | Re: Clustering/fail-over solution |