Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return value if exists in table 2

Status
Not open for further replies.

adonis547

MIS
Oct 19, 2004
16
FR
Hello,

I've got the following table:

COMP_ID COMP_NAME COMP_PSEUDO
----------------------------------
1 ABC XXYXX
2 ORACLE YYXXY
3 DELL OOSSX
4 IBM
5 MS

So, (ABC,DELL & ORACLE) all subscribe to my fine Pseudo service, that enables them to be "cloaked" on my site. Meaning, instead of parsing DELL on my site, it'll say OOSSX.

IBM & MS will remain visible.

My question goes like this, is there a way (by fx. a trigger or something else) to return the COMP_PSEUDO field as COMP_NAME ?

Like this:
SELECT COMP_NAME FROM MY_TABLE;
-----------------
XXYXX
YYXXY
YYXXY
IBM
MS
-----------------

Any help much appreciated, thanks !

 
I presume you want the results as
XXYXX
YYXXY
OOSSX -- and not YYXXY, guess it was a typo.
IBM
MS

The following sql will give you comp_pseudo always if some value exists. Else.. it will return the name

SELECT DECODE(COMP_PSEUDO,NULL,COMP_NAME,COMP_PSEUDO) FROM MY_TABLE;
 
Another method would be:
Code:
select nvl(COMP_PSEUDO,COMP_NAME) from MY_TABLE;

Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
Author and Sole Proprietor of: Emu Products Plus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top