On Tue, 11 Jan 2000, Bruce Bantos wrote:
> In my current Oracle DB, I have a number of "lookup" tables
> that contain something like this:
You make a "lookup" function, and you call the
function in your select list.
It's been a few months since I've played with
PostgreSQL, so I don't remember the syntax.
An Oraclish example:
CREATE FUNCTION LOOKUP_CATEGORY_LONG_(VARCHAR2 ABBREV)
AS
myVar COMPANY_CATEGORY.COM_CAT_LONG%TYPE;
BEGIN
SELECT COM_CAT_LONG
INTO myVar
FROM COMPANY_CATEGORY
WHERE COM_CAT_ABBR = ABBREV;
RETURN myVar;
END;
SELECT COMPANY_NAME, LOOKUP_CATEGORY_LONG(COM_CAT_ABBR) CATEGORY
FROM COMPANY;