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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
Joining 3 tables
 Login/Join
 
Silver Member
posted
I have 3 SQL tables that I'd loke to join. Table A has dept_id, dept_descr. Table B has dept_id, subdept_id, subdept_descr. Table C has subdept_id, sales_amt.

How can I join these 3 tables so that I can get the following result:

dept_id, dept_descr, subdept_id, subdept_descr, sales_amt

Thanks!


7.6.6
Windows 2003 Server, Sybase IQ, DB2, SQL Server and Oracle Databases
Excel, HTML and PDF
 
Posts: 34 | Registered: February 20, 2008Report This Post
Silver Member
posted Hide Post
Joel

JOIN DEBPT_ID IN TABLEA TO ALL DEPT_ID IN TABLEB AS JAB
JOIN SUBDEPT_ID IN TABLEA TO ALL SUBDEPT_ID IN TABLEC AS JAC
TABLE FILE TABLEA
SUM SALES_AMT
BY DEPT_ID
BY DEPT_DESCR
BY SUBDEPT_ID
BY SUBDET_DESCR
END


7.7.04
Win2K3, Unix
Oracle 10G,SQL2K,XFOCUS,ESRI,BID,MRE,SELF-SERVICCE
 
Posts: 36 | Location: Melville,NY | Registered: August 09, 2004Report This Post
Guru
posted Hide Post
Hi Joel,

I would create a view on sql server doing these joins and create a master file on it.


CREATE VIEW [NameOfTheView]
AS
Select A.dept_id, A.dept_descr, B.subdept_id,B.subdept_descr, C.sales_amt
inner join B On A.dept_id=B.dept_id
inner joiin B.subdept_id=C.subdept_id
GO


WebFocus 7.6.5
AND WebLogic server as web server
sql2005 as database server
 
Posts: 273 | Location: Europe | Registered: May 31, 2007Report This Post
Platinum Member
posted Hide Post
Joel,

I agree wholeheartedly with Majid Jeddi's solution.

This is a fine example of how it's always better to push the hard work back into the RDBMS it you have the ability to do so. Sometimes, it's not easy because of user's security access, knowledge, DBA availability, etc.

Effecting the JOIN in the RDBMS will also cause a marked reduction in the elapsed time to produce the report.

Chris Burtt


WIN/2K running WF 7.6.4
Development via DevStudio 7.6.4, MRE, TextEditor.
Data is Oracle, MS-SQL.
 
Posts: 154 | Location: NY | Registered: October 27, 2005Report This Post
Gold member
posted Hide Post
Why the need to create a SQL View. Isn't that why WebFocus has the Join Tool? This appears to be a rather straight forward request.

I understand creating SQL Views/Stored Procedures sometimes makes it easier - but then you have the overhead of maintaining these views (and the master file).

I have some complicated WebFocus Reports with multiple hold-files, dialog-manager, multiple joins... (Some of created by me, others by IBI Consultants). Looking back at some reports, I think a Stored Procedure would have been a better solution. (Hey the reports work - why mess with them - except maybe they could be faster as stored proc!)

One disadvantage of a stored procedure is that unless you know exactly all the input parameters required beforehand - you are bringing back more data to SQLOUT than you need actually need. Then you do a "Where" with WebFocus to filter SQLOUT. So sometimes the stored proc solution is slower.

Here is my question ---

What is the perfect balance of "pushing the work back to the RDBMS" vs using Web-Focus (Dev-Studio)? I always seem to be faced with the decision - do I create another SQL view/stored procedure or do I do the little extra work in WebFocus (such as create the join).


Webfocus 7.6.4
Windows 2003 Server, SQL Server 2005
Excel, HTML , JavaScript ,and PDF.
Reportcaster, BID, Tomcat
 
Posts: 79 | Registered: May 02, 2006Report This Post
Master
posted Hide Post
I would say it depends on the number of tables, the size of the files, if you are having to pull data across platforms and if the join from fields all reside in the host. In this case, you are joining from FIELD1 in TABLEA to FIELD1 in TABLEB and from FIELD2 in TABLEB to FIELD2 in TABLEC. Unless the tables are very small, I would use a view.


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
 
Posts: 755 | Location: TX | Registered: September 25, 2007Report This Post
Expert
posted Hide Post
In my experience, I would suggest understanding what you are doing.

Are you using this view for other reports ?

There are benefits to using a Join in the fex as apposed to a join in the DB.

For example, if you reference the join in the DB and use columns from 2 of the 3 tables, an SQL DB will/may read all three tables, which adds up to overheads. Keep in mind that behind the scenes, a View is pretty much an SQL request.

What I have seen in the past is that different queries can have different efficiencies. A bit of testing can help.

The code we write here allways has a check of the time in between steps, so inefficient code can be spotted.

In fact with the Oracle DB we have (Pretty complex design), we have found that in many cases extracting each tables into flat files and then joining can be quicker that letting Oracle do the join.

Hope this helps


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Gold member
posted Hide Post
Waz - that was helpful!

I agree - you need to know all the facts first before you decide to create a view vs using WebFocus (Efficient/Responsive reports are important!)

I'm always being asked to create sql views/procedures with everything so the user can ad-hoc almost anything. So I end up with views that joins several tables and then they complain the report is slow - I can't win!.

So - I guess it boils down to this - it depends on what your doing!


Webfocus 7.6.4
Windows 2003 Server, SQL Server 2005
Excel, HTML , JavaScript ,and PDF.
Reportcaster, BID, Tomcat
 
Posts: 79 | Registered: May 02, 2006Report This Post
Expert
posted Hide Post
If the join is done properly, as in the code posted by Jimbo, then the join will be done by the RDBMS even without creating a view.

Run trace code when developing to verify that the join is being passed to the relational engine.

SET TRACEOFF = ALL
SET TRACEON = SQLAGGR//CLIENT
SET TRACEON = STMTRACE//CLIENT
SET TRACEON = STMTRACE/2/CLIENT
SET TRACESTAMP = OFF
SET TRACEWRAP = 78
SET TRACEUSER = ON
SET XRETRIEVAL=OFF


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Expert
posted Hide Post
Jammer, if you are creating many views in SQL, have you considered joins in the master. You will still get the benefits of a FOCUS join but you get the single view on the data.

I also agree with GinnyJakes, all of our code has SQL tracing on (set up in an environment prep include), a minor overhead for the output, but can be invaluable for diagnosis of issues and performance.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
Waz,

Be sure to comment out the include before rolling the program to production. The trace creates a file in edatemp that must be removed manually.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders