From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | David Bowen <dmb0317(at)frontiernet(dot)net> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #1370: Problem with arrays in PL/PGSQL |
Date: | 2005-01-03 17:56:35 |
Message-ID: | 20050103175635.GA58965@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Mon, Jan 03, 2005 at 03:11:05AM +0000, David Bowen wrote:
> test=# select crosstab(1);
> ERROR: array value must start with "{" or dimension information
> CONTEXT: PL/pgSQL function "crosstab" line 5 at block variables
> initialization
> $ cat /home1/dmb/crosstab
> CREATE OR REPLACE FUNCTION crosstab (integer) RETURNS integer[] AS '
> DECLARE
> contestant ALIAS FOR $1;
> row scores%ROWTYPE;
> s integer[3]:= (-1,-1,-1);
See "Array Value Input" in the "Arrays" section of the "Data Types"
chapter in the documentation; see also "Array Constructors" in the
"Value Expressions" section of the "SQL Syntax" chapter. Either
of the following should work:
s integer[3]:= ARRAY[-1,-1,-1];
s integer[3]:= ''{-1,-1,-1}'';
Since you're running 8.0, consider using dollar quotes around the
function body if backward compatibility isn't necessary -- that way
you don't have to escape single quotes that are inside the function.
See "Dollar-Quoted String Constants" in the "SQL Syntax" chapter.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | jan pfaler | 2005-01-03 21:16:35 | Re: rule-system revaluates the functionale expressions |
Previous Message | Tom Lane | 2005-01-03 17:40:02 | Re: rule system re-evaluates expressions |