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     Decode Function in Webfocus...

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Decode Function in Webfocus...
 Login/Join
 
Platinum Member
posted
Anybody having any clue on how to decode some values and not others.

Suppose in master file CAR, i only want to decode 'JAGUAR' VALUES TO 'HONDA' AND want to keep other values as same as in master file, wats the syntax ??

Below syntax not working.
Plz note : CAR is Hold file name as well as field name.

DEFINE FILE CAR
INDIACAR/A20=DECODE CAR( 'JAGUAR' 'HONDA' ELSE CAR );
END


WF Server: 7.1.4 on Z/OS and Linux, ReportCaster
Data: DB2, DB2/UDB, Adabas, SQL Server, Oracle Output: HTML,PDF,Excel2K
WF Client: Servlet, CGI
 
Posts: 133 | Registered: May 12, 2007Report This Post
Virtuoso
posted Hide Post
The syntax looks ok, it works with me.

What is your error message?




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
How about:
DEFINE FILE CAR
INDIACAR/A20 = IF CAR EQ 'JAGUAR' THEN 'HONDA' ELSE CAR;
END

Hope this helps.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Platinum Member
posted Hide Post
oh..kewl..it works...
Thanks a bunch gamp


WF Server: 7.1.4 on Z/OS and Linux, ReportCaster
Data: DB2, DB2/UDB, Adabas, SQL Server, Oracle Output: HTML,PDF,Excel2K
WF Client: Servlet, CGI
 
Posts: 133 | Registered: May 12, 2007Report This Post
Virtuoso
posted Hide Post
But your solution should work too.
The solution from G is in this case OK, but what if you decide to use this with 4 or 5 or 10 different fields??




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
Let's just say: We'll cross that bridge when we get to it....


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Expert
posted Hide Post
That'll be the Arnhem Bridge then - lol

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Well, that should be a bridge to far...




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Master
posted Hide Post
Lets not forget what the decode function is really for. To take some kind of code/value and translate it into an easy to understand meaningful description. If you only want to decode certain code then you have to use some kind of if then else logic.




Scott

 
Posts: 865 | Registered: May 24, 2004Report This Post
Virtuoso
posted Hide Post
So it's not allowed to use it as I (we) do?

..... Music




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Guru
posted Hide Post
In WebFOCUS with DECODE the ELSE value can not be a field name, it must be a literal. That can be confusing since, for instance, Oracle has a Decode function where the ELSE value can be a field name. Essentially you have to do it like GamP did it.


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
 
Posts: 391 | Location: California | Registered: April 14, 2003Report This Post
Virtuoso
posted Hide Post
N.

my solution is working with the ELSE fieldname...




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Expert
posted Hide Post
quote:
DEFINE FILE CAR
INDIACAR/A20=DECODE CAR( 'JAGUAR' 'HONDA' ELSE CAR );
END

The DECODE function is putting the character string 'CAR' into the field INDIACAR.
so the way to use decode would be something like:
INDIACAR/A20=DECODE CAR('JAGUAR' 'ALL MINE' ELSE ' ');
or
INDIACAR/A20=DECODE CAR (filename ELSE ' ');
then
INDIACAR/A20=IF INDIACAR IS ' ' THEN CAR ELSE INDIACAR;
in this case the word CAR references a field, not a character string.
remembering that with DEFINEs, the last referenced define is the value pulled in a TABLE request, which is one of those blessedly *gifted* features of wf we take for granted and can't live without. Wink




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Master
posted Hide Post
In sql the Decode function is used often to flip the axis of data. (denormalize data)
I'm sure there's a better term, but I don't know what it is.

Such as, if you have data of
Product Line
Sales $

To get the Sum of Sales for a Product Line you would have to do a
Select ProductLine, Sum(sales) from table group by ProductLine

but, what if you wanted to group those productlines together? As in you wanted to combine something like Soap and Shampoo

Select
sum(Case when productline in ('Soap','Shampoo') then Sales else 0 end) as "ShowerSupplies',
Sum(case when productline NOT in
('Soap','Shampoo') then Sales else 0 end) as "Everything_But_ShowerSupplies'
from sometable

Comes in handy more than one might think. Thought I'd bring it up.


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
 
Posts: 611 | Registered: January 04, 2007Report 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     Decode Function in Webfocus...

Copyright © 1996-2020 Information Builders