[Info-Ingres] changing result of select query in tablefield
ghingres at yahoo.co.uk
ghingres at yahoo.co.uk
Mon Apr 21 13:33:54 CDT 2008
The ideal way would be as part of the SQL to perform a join to a
reference table. This would then allow you to retrieve the description
for each val2 occurance. So create a table tbl2 with two columns (val2
and val2_description), populate it with abbreviations and descriptions
and then change the SQL to be something like this: -
tblField = SELECT
t.val1, t.val2, r.val2_description, t.val3
FROM
tbl1 t,
tbl2 r
WHERE
tbl2.val2 = tbl1.val2
If you cannot be certain you will have all the values of val2 in the
tbl2 reference table then you would use a tbl1 LEFT JOIN tbl2 and
ensure you put a IFNULL(r.val2_description,'No description') on the
SELECT statement.. shout if you don't understand this concept.
Depending on your Ingres version you can also use a CASE statement in
the SQL - but I wouldn't think that was a good idea (before anybody
slates me for suggesting...)
If you don't want to go down the SQL route, (guessing ABF because of
the tblField := statement)... you could just loop through the records
in the table field (it is an array remember) and update the necessary
description fields... (see unloadtable as an example).
Hope this helps
Gary
More information about the Info-Ingres
mailing list