Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] DECODE: Using a field value for default

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] DECODE: Using a field value for default
 Login/Join
 
Gold member
posted
I am hoping this is a stupid question, but I am having trouble finding documentation for it. Maybe someone can easily answer for me:

Here is the scenario: I am using DECODE to reassign some field values. Pretty straight forward.

So,

DECODE FIELD1('The Fieldname Value A' 'A'
'The Field Value B' 'B' ...


That sort of thing. But instead of assigning a default literal value, like: ELSE 'Other', I want to use the incoming field value if that value has not been included in the DECODE.

So, instead of:

DECODE FIELD1('The Fieldname Value A' 'A'
                    'The Field Value B' 'B'
                    ELSE 'Other');



I want something like:

DECODE FIELD1('The Fieldname Value A' 'A'
                    'The Field Value B' 'B'
                    ELSE FIELD1);




Where the table value of FIELD1 is displayed, if a decoded value has not been supplied for that field value.

I am sure that I had some method of doing this at some point (and that it was simple), but I'm banging my head on the desk a bit trying to figure it out now. I am sure that I could do it with a couple of DEFINE fields, but I am trying to avoid getting into a large, convoluted IF THEN ELSE statement.

Any tips would be appreciated.

This message has been edited. Last edited by: Kerry,
 
Posts: 52 | Location: Merrimack, NH | Registered: August 17, 2006Report This Post
Virtuoso
posted Hide Post
You could try something like this.

DEFINE FILE CAR
NEWCAR/A20 =   DECODE CAR ('JAGUAR' 'JAG' 'JENSEN' 'JEN' );
NEWCAR2/A20 = IF NEWCAR NE ' ' THEN NEWCAR ELSE CAR;
END
TABLE FILE CAR
PRINT CAR NEWCAR NEWCAR2
END
  


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
Virtuoso
posted Hide Post
@Prairie

Maybe it works as is, but I always make the default of a DECODE assignment explicit:

... = DECODE CAR ('JAGUAR' 'JAG', 'JENSEN' 'JEN', ELSE ' ');
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Virtuoso
posted Hide Post
Jack,

Do you always put commas in your DECODE?
I tested it and IT WORKS although never mentioned in the documentation!
Another WF wonder?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Virtuoso
posted Hide Post
The bottom of the function definition in the documentation says:
quote:
You can use up to 40 lines to define the code and result pairs for any given DECODE function, or 39 lines if you also use an ELSE phrase. Use either a comma or blank to separate the code from the result, or one pair from another.


So in practice you can put those comma's wherever you like and it should work.

So apparently you could also write it as:
... = DECODE CAR ('JAGUAR','JAG' 'JENSEN','JEN' ELSE '');
... = DECODE CAR ('JAGUAR','JAG','JENSEN','JEN',ELSE '');


I am a bit surprised that a comma before the ELSE statement is accepted though!


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
<JG>
posted
is mentioned

quote:
You can use up to 40 lines to define the code and result pairs for any given DECODE function,
or 39 lines if you also use an ELSE phrase. Use either a comma or blank to separate the
code from the result, or one pair from another.


Wep5622 just beat me
 
Report This Post
Virtuoso
posted Hide Post
j.gross - yes the ELSE ' ' should be added.

Interesting about the comma...
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] DECODE: Using a field value for default

Copyright © 1996-2020 Information Builders