Re: Count(*) throws error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Count(*) throws error
Date: 2007-07-11 21:42:43
Message-ID: 3405.1184190163@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

"Jasbinder Singh Bali" <jsbali(at)gmail(dot)com> writes:
> I'm using the following statement in my plpgsql function

> SELECT INTO no_rows COUNT(*) FROM tbl_concurrent;

> I have decalred no_rows int4 and initialized it to zero

> Running the function throws the following error:

> ERROR: syntax error at or near "(" at character 13
> QUERY: SELECT $1 (*) FROM tbl_concurrent

I'll bet a nickel you have a local variable named "count" in that
function, and plpgsql is blindly trying to substitute its value into
the SQL query. The replacement of "COUNT" by " $1 " in the query
text is the tip-off.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Simon Riggs 2007-07-11 21:59:36 Re: [GENERAL] Count(*) throws error
Previous Message Bohdan.Linda 2007-07-11 21:34:00 Re:[GENERAL] auditing question - PARTIALY SOLVED

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-07-11 21:47:25 Re: 2PC-induced lockup
Previous Message Simon Riggs 2007-07-11 21:41:45 Re: 2PC-induced lockup