Search Postgresql Archives

Re: ECPG: non-integer constant in group by

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2006-09-15, Poul Jensen <flyvholm@xxxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux