Help! problem with SQL statement in Delphi, emergency!

Hi, I am using Delphi, and I am filling in a database grid with a rather complicated query that looks like this:

SELECT b.Account_No, b.NTSELECT, MAX(b.Tot_Score) as Tot_Score, MAX(b.Tot_Hits) as Tot_Hits, MAX(a.Today_Hit) as Today_hit, MAX(b.TransDt_Dt) as TransDt_Dt, MAX(b.Posting_Dt) as Posting_Dt, MAX(a.FraudLevel) as FraudLevel,MAX(b.Short_Name) as Short_Name, MAX(b.TaxId_Ind) as TaxId_Ind, MIN(b.CollectBal) as CollectBal, MAX(b.DTOpen_Dt) as DTOpen_dt, MAX(b.CurLdgrBal) as CurLdgrBal, MAX(b.AverageBal) as AverageBal FROM R0_Red b, ACCTSUMM a
WHERE a.Account_No = b.Account_No AND b.BankBranch = 4
AND b.Ball = 'T' AND b.Posting_dt = '28-OCT-2002'
GROUP BY b.Account_No, b.NTSELECT
ORDER BY b.Account_No ASC


Now, the trouble is the fields b.NTSELECT. This query worked fine, and gave us a fully functional read-only data grid before this field was added. It has now been requested that we allow the user to update a boolean field, NTSELECT, in the R0_Red table on the fly.

Right from the beginning, I am uneasy about using being able to update records in a source dataset (R0_Red) by playing around on the screen with the true/false value of a boolean field sitting in the RESULT data set. However, I probably don't need to worry about that YET, as the query above simply *does not work*. NTSELECT is a logical (boolean) field defined in R0_Red. If I remove those two references to it, everything works fine, when I add them, I get back an ODBC/SQL error that says "TOO FEW PARAMETERS - EXPECTED 1".

Does anyone have any idea how to do this?

Many thanks to anyone who can help,
Rusty

Comments

  • It sounds as if it does not like your Order by clause. I do not know what database you are bouncing against, but it has been my experience that sometimes null values can play havoc with a query. You might check the values in the NTSELECT column to determine if any are null.

    : Hi, I am using Delphi, and I am filling in a database grid with a rather complicated query that looks like this:
    :
    : SELECT b.Account_No, b.NTSELECT, MAX(b.Tot_Score) as Tot_Score, MAX(b.Tot_Hits) as Tot_Hits, MAX(a.Today_Hit) as Today_hit, MAX(b.TransDt_Dt) as TransDt_Dt, MAX(b.Posting_Dt) as Posting_Dt, MAX(a.FraudLevel) as FraudLevel,MAX(b.Short_Name) as Short_Name, MAX(b.TaxId_Ind) as TaxId_Ind, MIN(b.CollectBal) as CollectBal, MAX(b.DTOpen_Dt) as DTOpen_dt, MAX(b.CurLdgrBal) as CurLdgrBal, MAX(b.AverageBal) as AverageBal FROM R0_Red b, ACCTSUMM a
    : WHERE a.Account_No = b.Account_No AND b.BankBranch = 4
    : AND b.Ball = 'T' AND b.Posting_dt = '28-OCT-2002'
    : GROUP BY b.Account_No, b.NTSELECT
    : ORDER BY b.Account_No ASC
    :
    :
    : Now, the trouble is the fields b.NTSELECT. This query worked fine, and gave us a fully functional read-only data grid before this field was added. It has now been requested that we allow the user to update a boolean field, NTSELECT, in the R0_Red table on the fly.
    :
    : Right from the beginning, I am uneasy about using being able to update records in a source dataset (R0_Red) by playing around on the screen with the true/false value of a boolean field sitting in the RESULT data set. However, I probably don't need to worry about that YET, as the query above simply *does not work*. NTSELECT is a logical (boolean) field defined in R0_Red. If I remove those two references to it, everything works fine, when I add them, I get back an ODBC/SQL error that says "TOO FEW PARAMETERS - EXPECTED 1".
    :
    : Does anyone have any idea how to do this?
    :
    : Many thanks to anyone who can help,
    : Rusty
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion