Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Is there a way in Webfocus/Infoassist to use CASE statements as sql does.
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Is there a way in Webfocus/Infoassist to use CASE statements as sql does.
 Login/Join
 
Member
posted
Is there a way in Webfocus/Infoassist to use CASE statements as sql does.

Example:

case WHEN TIMESTAMPDIFF(SQL_TSI_DAY, CAST("LOB Dimension".LOB_RCVD_001 AS DATE),CAST (CURRENT_DATE AS DATE) ) BETWEEN 6 AND 10 then "Work Fact".Count else 0 end

Here When i Say LOB_RCVD_001 it is Application Received date.

Wanted to know how to have this Query set in Infoassist to get the results with the count for the days given above

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8

Windows, Active Report
 
Posts: 1 | Registered: May 10, 2018Reply With QuoteReport This Post
Virtuoso
posted Hide Post
My SQL is rusty. Could you explain what you're trying to accomplish? From what I can tell, this is just an IF THEN ELSE in a DEFINE or a COMPUTE but maybe there's more to it than that.


WebFOCUS 8204, Unix, Windows
 
Posts: 1617 | Location: New York City | Registered: December 30, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Use something such as (in a DEFINE or COMPUTE):

DateDiff /I3 = HDIFF(CURRENT_DATE, LOB_RCVD_001, 'day-of-year', 'I3');
TestDiff /I5 = IF DateDiff GE 6 and DateDiff LE 10 THEN Count ELSE 0;

Look into manual/help for how to use HDIFF and its component format/usage.


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2100 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Expert
posted Hide Post
Yes!

A CASE command that is encountered in the sequential flow of a procedure is not executed.

You assign a unique name to each function using the CASE command.

Syntax: How to Use the CASE Command
The syntax for the CASE command is:

CASE functionname [TAKES p1/t1[,..., pn/tn]] [RETURNS result/t] [;]
[declarations]
commands
.
.
.
ENDCASE

Source: F1/Help from within App Studio.
 
Posts: 2967 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
quote:
CASE functionname [TAKES p1/t1[,..., pn/tn]] [RETURNS result/t] [;]


I think you will find that CASE is in Maintain.

You should be able to issue ANSI SQL with a case command against any data source.

SQL
select country
case
when country = 'ENGLAND' then 'UK'
when country in ('W GERMANY','ITALY','FRANCE') then 'EUROPE'
else 'Other' END
from car
;
END


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6069 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
quote:
CASE is in Maintain

Really, Maintain Only??? OK, if so, I stand corrected.
 
Posts: 2967 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
quote:
Really, Maintain Only??? OK, if so, I stand corrected.


Well, in relation to 8.1.04, haven't checked 8.2 documentation


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6069 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
"CASE Statements": Sounds like it should be a NFR...
 
Posts: 2967 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
Master
posted Hide Post
quote:
Originally posted by Doug:
"CASE Statements": Sounds like it should be a NFR...


How is CASE different than DECODE? I have numerous requests where I have a WHERE on a DECODE value in a DEFINE and when I look at the SQL generated, the DECODE is converted to a SQL CASE statement.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 905 | Location: Oklahoma City | Registered: October 27, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
quote:
How is CASE different than DECODE?


SQL CASE supports returning the results of a formula.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6069 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
As mentioned by someone before, I think with IF THEN ELSE IF THEN ELSE IF .... you can do what CASE does in SQL. Actually if you look at the generated SQL you will find that IF THEN ELSE in a DEFINE or COMPUTE will be translated into a CASE statement.


WebFocus 7.7.06M/8.2.03M, iWay DataMigrator, Windows, DB2 Windows V10.5, MS SQL Server, Azure SQL, Hyperstage, ReportCaster
 
Posts: 149 | Registered: March 29, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Is there a way in Webfocus/Infoassist to use CASE statements as sql does.

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.