Re: ECPG: non-integer constant in group by

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Poul Jensen <flyvholm(at)gfy(dot)ku(dot)dk>
Cc: andrew+nonews(at)supernews(dot)com, Joachim Wieland <joe(at)mcknight(dot)de>, pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: ECPG: non-integer constant in group by
Date: 2006-09-16 12:07:47
Message-ID: 20060916120747.GC19244@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Sep 16, 2006 at 03:47:28AM -0800, Poul Jensen wrote:
> Thank you for your replies. My next attempt was:
>
> for (i=0; i<NVARS; i++)
> {
> sprintf(stmt,"SELECT %s FROM beamdata GROUP BY %s;",vars[i],vars[i]);
> EXEC SQL EXECUTE IMMEDIATE :stmt;
> n_occ[i] = sqlca.sqlerrd[2];
> }

I've never used ECPG, but from the manual it seems the following should
work:

for (i=0; i<NVARS; i++)
{
sprintf(stmt,"SELECT %s FROM beamdata GROUP BY %s;",vars[i],vars[i]);
EXEC SQL PREPARE mystmt FROM :stmt;
EXEC SQL EXECUTE mystmt INTO wherever;
n_occ[i] = sqlca.sqlerrd[2];
}

I don't know what the n_occ line does, so I left it alone but maybe
that needs changing too.

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-09-16 13:13:40 Re: Superuser lost access to particular database
Previous Message Poul Jensen 2006-09-16 11:47:28 Re: ECPG: non-integer constant in group by