No. You have two choicesThank's, taazz! Not sure I have understand everything, but will try to discover.
1)write an ongettext/onsetetxt event handler for the field you are interested in return the appropriate text to be sown on the grid.
2)add a lookup field on the sqlquery that does not exists in the database, connect its dataset property to the TBufDataset its keyfields property to your database field and its lookupKeys and resultfield to the appropriate bufdataset fields. the lookupkey will be the field that has the same value as your KeyField and resultfield is a text/string field that will show what ever your want for that value.
@Voldink, try:
... DBForm.DBquery.SQL.text := 'select termtype, callstart, callend, origin, destination, direction from callrecord'; ... procedure TForm1.DBQuery1TERMTYPEGetText(Sender: TField; var aText: string; DisplayText: Boolean); begin if (DisplayText) then begin case Sender.Value of 0: aText := 'None'; 1: aText := 'Incoming'; 2: aText := 'Outgoing'; 3: aText := 'Internal'; else aText := 'Unknown2'; end; end else aText := 'Unknown1'; end; procedure TForm1.SQLQuery1TERMTYPESetText(Sender: TField; const aText: string); begin if (aText = 'None') then Sender.Value := 0; if (aText = 'Incoming') then Sender.Value := 1; if (aText = 'Outgoing') then Sender.Value := 2; if (aText = 'Internal') then Sender.Value := 3; end;
valdir.marcos, these procedures are for taazz's variant 1?
Friend, take a look at the attachment.ezlage, I'm using this, thanks!
@Vodnik,@vrull, I can't. The SW product that is using this DB restricts changing DB. It also restricts querying more than 10000 records at a time. And is very sensible to table locking time. Known practice is to create a replication to another DB and work with it, but I'm not yet good enough to do this. Then IDs can be replaced with text. BUT: More bytes -> more space -> more memory -> more processing time, isn't it?
If you can modify the database, it is easier to make a lookup table to keep all your Ids with user-readable descriptions.
The point is if you work with SQL you can always construct a query which would give you all data you need. You can run that query independently from your program and make sure all your results are correct.
Then you make a program which just reads the result of that query and presents data to the end user; it formats data to make it look nice, but does not modifies anything.
With this approach you separate user interface from data processing, you know where to look if something went wrong. SQL is very powerful language, it can do almost everything with you data.