• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

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!
0
Marius0188
Asked:
Marius0188
  • 4
1 Solution
 
mikelittlewoodCommented:
Which of your fields is a BLOB field as if I remember right you can't use it as part of a GROUP
0
 
Marius0188Author Commented:
Field: MESSAGESOURCE  is ftBlob.

0
 
mikelittlewoodCommented:
Also just as a side note I would not probably label a column as ROWCOUNT as this might be reserved.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
mikelittlewoodCommented:
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
--------------------------------------------------------------------------------------------------
0
 
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
0
 
mikelittlewoodCommented:
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)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now