Re: [SQL] Converting column values on a select - Mailing list pgsql-sql

From tjk@tksoft.com
Subject Re: [SQL] Converting column values on a select
Date
Msg-id 199910130155.SAA05966@uno.tksoft.com
Whole thread Raw
In response to Converting column values on a select  ("Saltsgaver, Scott" <scottsa@aiinet.com>)
List pgsql-sql
It seems like you are looking for something like this:

select ct.statusValue from conversionTable ct, networkTable nt where ct.statusText = nt.status;


Troy

>
> I was wondering if it is possible to convert a text value to an integer
> value on a select to a table using another table as a conversion.  I looked
> into the "create rule" call but can't seem to get it to work.  Of course the
> code uses the numerical values for the status but I thought it would be nice
> if users who performed queries against that network equipment tables could
> see the nice text for the status.
>
> If it is possible to convert the text to a numerical is the reciprocal also
> possible so again the code does not have to perform
>
> Here is the status conversion table:
>
> statusValue     statusText
>       2                   normal
>       4                   critical
>       7                    major
>
> I then have a table that contains network equipment.
>
> network_equp_id        status         location        contact
>           20                   normal        2nd floor         Joe
>           19                   critical        basement       Fred
>
> Thanks,
>
> Scott Saltsgaver
>
> ************
>
>

pgsql-sql by date:

Previous
From: "Ismail Kizir"
Date:
Subject: pqReadData() -- backend closed the channel unexpectedly.
Next
From: "Jim Seach"
Date:
Subject: Re: [SQL] Converting column values on a select