Re: ECPG: non-integer constant in group by - Mailing list pgsql-general

From Andrew - Supernews
Subject Re: ECPG: non-integer constant in group by
Date
Msg-id slrnegl1v4.2ea3.andrew+nonews@atlantis.supernews.net
Whole thread Raw
In response to ECPG: non-integer constant in group by  (Poul Jensen <flyvholm@gfy.ku.dk>)
List pgsql-general
On 2006-09-15, Poul Jensen <flyvholm@gfy.ku.dk> wrote:
> 2) The code below was meant to find the # of distinct elements for many
> columns, but fails with the message
>     sql error 'non-integer constant in GROUP BY'
>     thrown at the EXEC SQL EXECUTE statement. What is the problem?

>   char dbnm[50], *stmt = "SELECT ? FROM beamdata GROUP BY ?;";

That statement is not legal - parameters can only be used to substitute
_data_, not identifiers or syntax.

You would have to interpolate the column name directly into the query
(remembering to quote it with "" if needed) rather than use a parameter
for it.

--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

pgsql-general by date:

Previous
From: Achilleas Mantzios
Date:
Subject: Postgresql 7.4 migration to (partially) new disks
Next
From: nuggets72@free.fr
Date:
Subject: Installation with sources or with packages