I have a field called member_number in my table defined as member_number varchar(15);
If this field is null my sql return a small message instead. The message is longer than the 15 characters defined for the field.
If I simply say...
Code: Select all
SELECT
IFNULL(member_number,
      'membership number missing please contact secretary' ) AS MemberNumber
FROM
mytable;I understand this is due to a bug/feature in MySQL that causes it to always return the defined field size along with the field data, which TMyQuery seems to be using instead of the actual data size.
Looking at this posting http://forums.devart.com/viewtopic.php? ... ted#p39701
It is suggested to cast the result to a larger field if necessary. They used an earlier version of MyDAC but the sql suggested is below (in their code the REPLACE replaces a short string with a bigger one which resulted in truncation)
Code: Select all
SELECT
   CAST(REPLACE(r.proc_path,"Reports.exe" # 11 chars
                           ,"Reports2.exe" # 12 chars
                       ) 
	  AS CHAR(100)
	 ) proc_path2
   ,r.proc_path
FROM 
   proc_run r However, when I tried doing the same thing...
Code: Select all
SELECT
IFNULL(member_number, 
      CAST('membership number missing please contact secretary'  AS CHAR(100)  ) 
      )  AS MemberNumber
FROM
mytable;How can I get the message correctly returned from TMyQuery withought having to change the defined field size in the table?
BTW No truncation happens using the database manager SQLYog to run the query - even when not using CAST, so its possible it is to do with the way TMyQuery deals with it.