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.
You could use ARGLEN function to get the length, but that is unlikely to be passed to the SQL. Use SQL tracing to capture the SQL to check.
If the function is not passed to SQL then then your request is not going to be as efficient as you need. So look at using SQL. prefix to pass the function through, Should be something like SQL.LENGTH(SPRIDEN_ID) but you would need to check whether a define or compute would work better.
I have had success using this type of SQL function using a define within a synonym before, but you need to check using your synonym/code.
Good luck
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, 2004
You can do a COMPUTE, DEFINE OR WHERE, and, the length of SPRIDEN_ID in the DB is the 1st argument of ARGLEN:
TABLE FILE SPRIDEN SUM COMPUTE ID_LEN/I3 = ARGLEN(SPRIDEN_ID_LENGTH GOES HERE, SPRIDEN_ID, ID_LEN); NOPRINT BY SPRIDEN_ID WHERE SPRIDEN_NTYP_CODE EQ 'TWID'; WHERE SPRIDEN_ID LIKE 'T%' ; WHERE TOTAL ID_LEN > 7; END -EXIT
I don't think there's a way to efficiently translate the LENGTH function. You would have to create a DEFINEd column using the ARGLEN function. This would be for each row in the table. Then you could filter on this DEFINEd column.
Instead, try the DB_EXPR function, though I'm not sure how to pass the HAVING portion of the statement.
quote:
The DB_EXPR function inserts a native SQL expression exactly as entered into the native SQL generated for a FOCUS or SQL language request.
The DB_EXPR function can be used in a DEFINE command, a DEFINE in a Master File, a WHERE clause, a FILTER FILE command, a filter in a Master File, or in an SQL statement. It can be used in a COMPUTE command if the request is an aggregate request (uses the SUM, WRITE, or ADD command) and has a single display command. The expression must return a single value.
WebFOCUS Release 8.1 Version 05M > Reporting Language > Using Functions > Data Source and Decoding Functions > DB_EXPR: Inserting an SQL Expression Into a Request
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
Originally posted by Tom Flynn: You can do a COMPUTE, DEFINE OR WHERE, and, the length of SPRIDEN_ID in the DB is the 1st argument of ARGLEN:
TABLE FILE SPRIDEN SUM COMPUTE ID_LEN/I3 = ARGLEN(SPRIDEN_ID_LENGTH GOES HERE, SPRIDEN_ID, ID_LEN); NOPRINT BY SPRIDEN_ID WHERE SPRIDEN_NTYP_CODE EQ 'TWID'; WHERE SPRIDEN_ID LIKE 'T%' ; WHERE TOTAL ID_LEN GT 7; END -EXIT
Thanks Tom, this did the trick.
WebFocus 8.104 Windows 7 Entreprise, SP1
Posts: 82 | Location: Abbotsford BC | Registered: March 15, 2010
Note that it will work only if the column specified in the COMPUTE and WHERE TOTAL is not aggregated by a SUM... BY... because the WHERE TOTAL filters on the output, not on the input.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
Just for information, if you use ARGLEN, your request may result in the following warning messages -
FOC2565 - THE OBJECT OF IF/WHERE CANNOT BE CONVERTED TO SQL
FOC2566 - DEFINE EMAIL_LEN CANNOT BE CONVERTED TO SQL
FOC2590 - AGGREGATION NOT DONE FOR THE FOLLOWING REASON:
FOC2598 - FOCUS IF/WHERE TEST CANNOT BE PASSED TO SQL
However, using the SQL prefix function in the following code (MS SQL source), get passed to the SQL efficiently (-
DEFINE FILE WF_RETAIL
EMAIL_LEN/I9 = SQL.LEN(EMAIL_ADDRESS);
END
TABLE FILE WF_RETAIL
SUM
WF_RETAIL.WF_RETAIL_CUSTOMER.EMAIL_ADDRESS
EMAIL_LEN
BY WF_RETAIL.WF_RETAIL_CUSTOMER.ID_CUSTOMER
WHERE EMAIL_LEN LE 20
IF READLIMIT EQ 10
END
AGGREGATION DONE ...
SELECT
TOP 10 T2."ID_CUSTOMER",
MAX(T2."EMAIL_ADDRESS"),
SUM(LEN(T2."EMAIL_ADDRESS"))
FROM
_wf_retail_customer T2
WHERE
(LEN(T2."EMAIL_ADDRESS") <= 20)
GROUP BY
T2."ID_CUSTOMER"
ORDER BY
T2."ID_CUSTOMER";
0 NUMBER OF RECORDS IN TABLE: 10 LINES: 10
0 HOLDING HTML FILE ON PC DISK ...
Ultimately, this might depend upon your result set size?
TThis message has been edited. Last edited by: Tony A,
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, 2004
Thanks Tony, I hadn't considered that. At the moment the simple solution works, but I'll come back to this if I'm doing more complex work with string lengths.
WebFocus 8.104 Windows 7 Entreprise, SP1
Posts: 82 | Location: Abbotsford BC | Registered: March 15, 2010