I need to use a UNION to pull all records in my Contact table and if the record is linked to a company in the Vendor table show which vendor.
If I use either of the subqueries I don't have a problem but once combined with the UNION clause I have to DataTypeMap ALL the fields (except DateTime) or else TCRDBGrid shows their values as (MEMO).
Code: Select all
'SELECT Contact.*, Contact.First || " " || Contact.Last as Contact, "" AS Vendor, "0" AS Vendor_ID' +
' FROM Contact' +
' WHERE Contact.Cont_ID NOT IN (SELECT CONT_ID FROM VENDOR)' +
'UNION ' +
'SELECT Contact.*, Contact.First || " " || Contact.Last as Contact, Vendor.Company as Vendor, Vendor.Vendor_ID' +
' FROM Contact, Vendor' +
' WHERE Contact.Cont_ID != 0' +
' AND Contact.Cont_ID = Vendor.Cont_ID';

or I get 'String value is too long' errors.
Unfortunately getting one of these errors would more often than not lock up Delphi (the error message would appear but neither the Break or Continue buttons would function) requiring me to use Windows Taskmanager to terminate Delphi.

Aside from the above mentioned issues - how would I specify the DataTypeMap field size (such as I was having to create in the component interface) in code?
For example I'm using the following rule to handle the field Contact which is a concatenation of the FirstName & LastName fields:
Code: Select all
ltqryProduct.DataTypeMap.AddFieldNameRule('Contact', ftString);