Search Postgresql Archives

Re: ECPG: non-integer constant in group by

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

 



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];
}

It works, but throws error message "too few parameters" every time. I need to add INTO <host variable> (I do need to retrieve the data for later use anyway), but it appears I can't use EXECUTE IMMEDIATE with a host variable in the statement. So now I can only think of one way:

 EXEC SQL SELECT filenm INTO :filenms FROM beamdata GROUP BY filenm;
 n_occ[0] = sqlca.sqlerrd[2];
 EXEC SQL SELECT yr INTO :yrs FROM beamdata GROUP BY yr;
 n_occ[1] = sqlca.sqlerrd[2];
 <Repeat for all variables!!>

Works and will get the job done, but so repetitive that it's hard to accept. Is there no way to get away with a loop?

Poul Jensen


[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