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

From Martijn van Oosterhout
Subject Re: ECPG: non-integer constant in group by
Date
Msg-id 20060916120747.GC19244@svana.org
Whole thread Raw
In response to Re: ECPG: non-integer constant in group by  (Poul Jensen <flyvholm@gfy.ku.dk>)
Responses Re: ECPG: non-integer constant in group by
List 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@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Poul Jensen
Date:
Subject: Re: ECPG: non-integer constant in group by
Next
From: Michelle Konzack
Date:
Subject: Re: plz unsubscribe me