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     [SOLVED] wildcard and Postgres

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] wildcard and Postgres
 Login/Join
 
Platinum Member
posted
Hi Everyone

I have a strange problem while trying to use a wildcard against a Postgres database.

Say I am trying to filter on FIELDNAME for a string that starts with "C" and has a "G" in it.

  WHERE FIELDNAME LIKE 'C%G'; 


Webfocus returns the proper results. But when I look at the generated SQL that was sent to the DB, the WHERE is missing and
I see the message

(FOC2598) FOCUS IF/WHERE TEST CANNOT BE PASSED TO SQL : FIELDNAME

Obviously we need the where condition to go to the DB.

If I try

WHERE FIELDNAME LIKE '%C%G%';


Then it works and the where is passed to the DB. But that is not what I want. I need the string to start with "C".

I tested this against SQL Server and the problem does not occur. So it seems to be specific to Postgres.

Has anybody seen this behaviour before with Postgres? As I said, I am getting the proper results, but the generated SQL passed to the DB must contain the where for this to be usable.

Thanks

Jodye

This message has been edited. Last edited by: Kerry,


WF 8.0.0.5M
 
Posts: 246 | Location: Montreal, QC, Canada | Registered: October 01, 2003Report This Post
Expert
posted Hide Post
The problem isn't necessarily Progres - some WHERE statements cannot be translated to SQL by the data adapter.

Wouldn't "filter on FIELDNAME for a string that starts with "C" and has a "G" in it" be translated to
WHERE FIELDNAME LIKE 'C%G%'
which will most likely be passed to SQL. This is the behaviour in DB2: "C%G" does not get passed, but "C%G%" does.

By the way, what are those double LIKEs?


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
Thanks Francis

LIKE LIKE was a typo.

I tried
 WHERE FIELDNAME LIKE 'C%G%'; 


and you are right... it works.

Still what is wrong with "C%G"?

what if I want starts with C and ends in G with whatever in the middle?

Thanks!

Jodye


WF 8.0.0.5M
 
Posts: 246 | Location: Montreal, QC, Canada | Registered: October 01, 2003Report This Post
Expert
posted Hide Post
This is normal behaviour in a DBMS. For example, in this DB2 SQL -

No rows retrieved:
SELECT DAY_OF_WEEK FROM BASEL.TIME_D
WHERE DAY_OF_WEEK LIKE 'M%y'
FETCH FIRST 10 ROWS ONLY;

Some rows retrieved:
SELECT DAY_OF_WEEK FROM BASEL.TIME_D
WHERE DAY_OF_WEEK LIKE 'M%y%'
FETCH FIRST 10 ROWS ONLY;

My interpretation:

DAY_OF_WEEK is a CHARACTER column with a length of 10. For 'Monday', the 'y' is the 6th character, but 'M%y' is looking for a value where the last (10th) character is a 'y' and there aren't any. Unfortunately, 'M%y%' will retrieve values I am not interested in and would have to filter them out with some other method. In this case I would let WebFOCUS take care of the filter.

As you mention, this behaves as expected in MS SQL Server.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
Here's a potential solution: put both WHERE LIKE statements in the selection criteria, one gets translated to SQL, the other is taken care of by WebFOCUS - this would have the dbms return some rows which would be filtered by WebFOCUS, better than the dbms returning all rows which would be filtered by WebFOCUS...

WHERE FIELDNAME LIKE 'C%G%';
WHERE FIELDNAME LIKE 'C%G';


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
That is a great idea Francis. I will put both lines.

I still think it should work. If I write it as sql passthrough it works fine.

thanks!


WF 8.0.0.5M
 
Posts: 246 | Location: Montreal, QC, Canada | Registered: October 01, 2003Report This Post
Expert
posted Hide Post
Did you test the SQL pass-through on the Progres db or on the MS SQL Server db? I found that SQL pass-through did not work on a DB2 db but did work on MS SQL Server.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
I tested it on Postgres and it works fine.


WF 8.0.0.5M
 
Posts: 246 | Location: Montreal, QC, Canada | Registered: October 01, 2003Report This Post
Expert
posted Hide Post
Strange that it worked - I thought it would behave like DB2.

This SQL returns some rows:
SELECT T1."APPROV_OFFICER_NM" 
FROM db1.CUSTOMER T1
WHERE (T1."CUST_NM" LIKE 'R%K                   ') 
group BY
 T1."CUST_NM"
ORDER BY
 T1."CUST_NM" 
FOR FETCH ONLY;
Entering a specific number of blanks after the last character returns some rows, but not all the expected rows - this is how it behaves outside WebFOCUS, SQL run from a DB2 client tool.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
Firstly, Francis - you seem to be mixing up Postgres with Progress. Those are different databases. Postgres is a modern SQL relational database, Progress is an old beast based on a 4GL language other than SQL (although they claim to support SQL too).

To the original poster; Yes, your query should work just fine. I think the Postgres SQL adapter may be a bit too conservative there, although that query isn't going to perform well.

Maybe you can rewrite it to:
WHERE FIELDNAME LIKE 'C%';
WHERE FIELDNAME LIKE '%G';

That should result in the same results.


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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] wildcard and Postgres

Copyright © 1996-2020 Information Builders