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.
I'm trying to define a count field and am stuck on how to do this...
Every time a customer purchases something on our platform, a new record is created in this table which includes the CustomerID. I want to get a define in place that counts if this CustomerID has appeared previously in the table so I can know if this is a new or returning customer via a filter on the count. The SQL equivalent of this I have is this...
select CustomerID, count(*) from CustomerRegistration group by CustomerID having count(*) = 1This message has been edited. Last edited by: FP Mod Chuck,
TABLE FILE CustomerRegistration
SUM COMPUTE CNT/I10 = CNT.CustomerId
BY CustomerId
WHERE TOTAL CNT EQ 1;
END
Is there no other field to distinguish multiple Registration records for the same customer? You seem to not actually be interested in the counts, but rather in the non-existence of other records for the same customer.
Something like:
select CustomerId
from CustomerRegistration R1
where not exists (
select 1
from CustomerRegistration R2
where R2.Customerid = R1.CustomerId and R2.RegistrationDate <> R1.RegistrationDate
)
The principle is called a "correlated subquery". It is usually a faster query than one using COUNT, as COUNT has to visit every record per customer, while NOT EXISTS can stop looking as soon as a 2nd record is encountered.
WebFOCUS has an equivalent for that in the DB_INFILE function, where EXISTS can be tested using WHERE DB_INFILE(...) EQ 1; and NOT EXISTS using WHERE DB_INFILE(...) EQ 0;. Leaving the equality comparison out translates to WHERE EXISTS too.
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 :
TABLE FILE CustomerRegistration
SUM COMPUTE CNT/I10 = CNT.CustomerId
BY CustomerId
WHERE TOTAL CNT EQ 1;
END
Is there no other field to distinguish multiple Registration records for the same customer? You seem to not actually be interested in the counts, but rather in the non-existence of other records for the same customer.
Something like:
select CustomerId
from CustomerRegistration R1
where not exists (
select 1
from CustomerRegistration R2
where R2.Customerid = R1.CustomerId and R2.RegistrationDate <> R1.RegistrationDate
)
The principle is called a "correlated subquery". It is usually a faster query than one using COUNT, as COUNT has to visit every record per customer, while NOT EXISTS can stop looking as soon as a 2nd record is encountered.
WebFOCUS has an equivalent for that in the DB_INFILE function, where EXISTS can be tested using WHERE DB_INFILE(...) EQ 1; and NOT EXISTS using WHERE DB_INFILE(...) EQ 0;. Leaving the equality comparison out translates to WHERE EXISTS too.
Where would I put the DB_INFILE piece? You're right, that does seem much more efficient. Sorry, I'm very new (only been usuing WebFOCUS for a few weeks)
You could try to look up the information on the db_infile function using the various help mechanisms available to you. There is a quite useful help file installed with my App Studio, called function.chm. It contains very complete information on all standard functions included in WebFocus.
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
It has to work with BUE? The British University in Eqypt? (According to Google/Wikipedia)
Well, whatever that means, you can just as easily assign the result of DB_INFILE to a virtual field and test on that in your WHERE filter.
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 :
If BUE (Business Users Edition) allows you to create and reuse hold files you could just sum the count by the customerid and hold it. Then join the main file to the hold file using left outer that should give you a count and (null or zero) for the customerids that are not in there.
If you are just trying to see if the customer id is in the database table, then you also do it with a define using the DB_LOOKUP function and have it return the customer id.
Then if the customer id is blank or is missing (if the customer id column in the table has nulls on) then you know its a first time else its a returning customer.