Re: Count(*) throws error

From: aklaver(at)comcast(dot)net (Adrian Klaver)
To: "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Count(*) throws error
Date: 2007-07-11 21:14:46
Message-ID: 071120072114.10288.46954846000150090000283022007614389D0A900E04050E@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-------------- Original message ----------------------
From: "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com>
> Hi,
>
> 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
> CONTEXT: SQL statement in PL/PgSQL function "sp_insert_tbl_concurrent" near
> line 8
>

Try SELECT COUNT(*) INTO no _rows FROM tbl_concurrent;
See
http://www.postgresql.org/docs/8.2/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-ASSIGNMENT
for complete syntax.
> If i comment this count(*) line, the error goes.
>
> I don't know why isn't count(*) working
>
> Thanks
> Jas

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo De León 2007-07-11 21:21:31 Re: Count(*) throws error
Previous Message Erik Jones 2007-07-11 21:14:02 Re: Count(*) throws error