From: | Poul Jensen <flyvholm(at)gfy(dot)ku(dot)dk> |
---|---|
To: | Joachim Wieland <joe(at)mcknight(dot)de> |
Cc: | pgsql-general General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: ECPG: non-integer constant in group by |
Date: | 2006-09-15 22:44:33 |
Message-ID: | 450B2CD1.4000408@gfy.ku.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Joachim Wieland wrote:
> On Fri, Sep 15, 2006 at 02:40:49AM -0800, Poul Jensen wrote:
>
>> 1) It seems like the fastest way to find the # of distinct elements in a
>> column is using GROUP BY. With ECPG, if I try
>> EXEC SQL SELECT filenm FROM beamdata GROUP BY filenm;
>> I will get "sql error Too few arguments". Why? Can I correct the
>> query to avoid the error message? (sqlca.sqlerrd[2] does contain the #
>> of elements in spite of error)
>>
> The problem is that you are selecting a value but you don't say where ecpg
> should store the result. You're missing the "INTO :var" part.
>
Thank you; that makes sense. I'm not sure why it's considered an error
though. Documentation says "Any SQL command can be run...", and why not.
The other problem I posted is worse and is what's really keeping me
stuck. Why are my text strings considered unacceptable "non-integer
constants"? Here are the relevant lines of code:
#define NVARS 24
EXEC SQL BEGIN DECLARE SECTION;
char *vars[NVARS] = { "filenm", "yr", "mo", "dy", "hr", "mt", "sc",
"us", "stat_id", "bmnum", "channel", "scnflag",
"cp_id", "intt", "intt_us", "frang", "rsep",
"tfreq", "noise", "natten", "nave", "nrang",
"gsct", "isct" };
char *stmt = "SELECT ? FROM beamdata GROUP BY ?;";
EXEC SQL END DECLARE SECTION;
EXEC SQL PREPARE query FROM :stmt;
for (i=0; i<NVARS; i++)
{
EXEC SQL EXECUTE query USING :vars[i], :vars[i];
}
Fails at EXECUTE with error message:
sql error 'non-integer constant in GROUP BY'
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Treat | 2006-09-16 00:28:59 | Re: PostgreSQL slammed by PHP creator |
Previous Message | Angva | 2006-09-15 22:17:38 | create index in parallel? |