Delphi TIBQuery Error

Hi Friends,

I have a TIBQuery component and receive an error when running my SQL query.
This is the SQL statement:
-----------------------------------SQL STATEMENT-------------------------------------
SELECT '+
    'CUSTOMEREMAILINID, CUSTOMERID, EMAILDATE, FROMEMAIL, HASREAD, MESSAGESOURCE, SUBJECT, TOEMAIL, ' +
    'COUNT(CUSTOMEREMAILINID) AS ROWCOUNT ' +
    'FROM '+
    'TBLCUSTOMEREMAILSIN ' +
    'WHERE ' +
    'CUSTOMERID = :CUSTOMERID ' +
    'GROUP BY '+
    'CUSTOMEREMAILINID, CUSTOMERID, EMAILDATE, FROMEMAIL, HASREAD, MESSAGESOURCE, SUBJECT, TOEMAIL '+
    'ORDER BY '+
    'EMAILDATE, CUSTOMERID
--------------------------------------------------------------------------------------------------

The error message I receive when opening the query is:
"conversion error from string 'BLOB' ".

Can someone please advice.

Thanks a million!
Marius0188Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike LittlewoodEngineerCommented:
Which of your fields is a BLOB field as if I remember right you can't use it as part of a GROUP
Marius0188Author Commented:
Field: MESSAGESOURCE  is ftBlob.

Mike LittlewoodEngineerCommented:
Also just as a side note I would not probably label a column as ROWCOUNT as this might be reserved.
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Mike LittlewoodEngineerCommented:
Assuming that CUSTOMEREMAILINID is the unique field on this table, try changing to a nested query to get the message (indexing the primary column will speed this up if the table is large).

SELECT '+
    'CUSTOMEREMAILINID, CUSTOMERID, EMAILDATE, FROMEMAIL, HASREAD, SUBJECT, TOEMAIL, ' +
    'COUNT(CUSTOMEREMAILINID) AS ROWCOUNT, ' +
    '(SELECT MESSAGESOURCE FROM TBLCUSTOMEREMAILSIN WHERE CUSTOMEREMAILINID = T.CUSTOMEREMAILINID) AS MESSAGESOURCE ' +
    'FROM '+
    'TBLCUSTOMEREMAILSIN T ' +
    'WHERE ' +
    'CUSTOMERID = :CUSTOMERID ' +
    'GROUP BY '+
    'CUSTOMEREMAILINID, CUSTOMERID, EMAILDATE, FROMEMAIL, HASREAD, SUBJECT, TOEMAIL '+
    'ORDER BY '+
    'EMAILDATE, CUSTOMERID
--------------------------------------------------------------------------------------------------

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TheRealLokiSenior DeveloperCommented:
I don't think you can use a blob in a "group by"
you could try declaring it as a memo type instead
Mike LittlewoodEngineerCommented:
Yeah thats why I re-wrote his query as a nested one just to bring back the blob field (if he doesnt need to group by it)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.