From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Jay O'Connor" <joconnor(at)cybermesa(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PLPGSQL problem with SELECT INTO |
Date: | 2003-05-29 21:41:29 |
Message-ID: | 2783.1054244489@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Jay O'Connor" <joconnor(at)cybermesa(dot)com> writes:
> CREATE FUNCTION countRows (varchar, varchar) RETURNS int AS
> '
> DECLARE
> val1 ALIAS FOR $1;
> val2 ALIAS FOR $2;
> total int;
> BEGIN
> SELECT INTO total count(*) FROM mytable WHERE fieldone =
> val1 AND fieldtwo = val2;
> RETURN total;
> END;
> ' LANGUAGE PLPGSQL;
> The value returned is much higher. Actaully, it is exactly what the number
> should be without the AND query. No matter what I'. passing for the second
> variable, I get the same result (even if it's a value not in that column
> for any record)
I kinda suspect you have an unexpected variable substitution. Is the
above *exactly* how the offending function reads, or have you
editorialized on the names used?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jay O'Connor | 2003-05-29 21:53:21 | PLPGSQL problem with SELECT INTO |
Previous Message | lyris-pg | 2003-05-29 21:26:16 | Re: fomatting an interval (resend) |