Re: ECPG: non-integer constant in group by

From: Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ECPG: non-integer constant in group by
Date: 2006-09-15 11:00:52
Message-ID: slrnegl1v4.2ea3.andrew+nonews@atlantis.supernews.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2006-09-15, Poul Jensen <flyvholm(at)gfy(dot)ku(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-09-15 11:15:48 Re: Installation with sources or with packages
Previous Message Achilleas Mantzios 2006-09-15 10:44:33 Postgresql 7.4 migration to (partially) new disks