Re: ODBC: SQLExecute fails when I add Oracle function SUM

From: Xingshan He <xingshan_he_at_hotmail.com>
Date: 2 Jun 2003 15:18:01 -0700
Message-ID: <37e4d47.0306021418.5ea5ddda_at_posting.google.com>


This is most likely caused by the column 'date' that is in your select list, but not in your group by list. All columns in your select list, except those that has an aggregate function around, must appear in your group by list. And vice versa.

If you run your sql thru sql-plus, you are probably getting ORA-00979 error.

od488gw02_at_sneakemail.com (chris) wrote in message news:<c452700a.0305301509.467278e3_at_posting.google.com>...
> The code below worked perfectly when I didn't have the SUM function in
> the select statement, but when I add it fails at SQLExecute call with:
>
> Fri May 30 16:23:37 2003 - S1000:1:921:[Oracle][ODBC][Ora]ORA-00921:
> unexpected end of SQL command
>
> Here's the code:
>
> sprintf(selectstatement,
> "select SUM(amount), date from pago where account_no = 10 and status =
> 0 group by payment_due_date");
>
> // Prepare the SQL statement by assigning it to the statement handle
> retval = SQLPrepare(hstmt, (SQLCHAR*) selectstatement,
> sizeof(selectstatement));
>
> if ((retval != SQL_SUCCESS) && (retval != SQL_SUCCESS_WITH_INFO))
> {
> // Prepare failed, call SQLGetDiagRec for errors.
> }
>
> // Execute the SQL statement handle
> retval = SQLExecute(hstmt);
>
> if ((retval != SQL_SUCCESS) && (retval != SQL_SUCCESS_WITH_INFO))
> {
> // Execute failed, call SQLGetDiagRec for errors.
> }
>
> Any idea what is wrong? Thanks.
>
> chris
Received on Tue Jun 03 2003 - 00:18:01 CEST

Original text of this message