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     Utility to perform SQL UNION in WebFOCUS

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Utility to perform SQL UNION in WebFOCUS
 Login/Join
 
Master
posted
Webfocus' support to carry out file concatenation exists but is not very user friendly.

1. FILEDEF BOTH DISK BOTH.FTM ( APPEND 
   TF 1 
   ON TABLE HOLD AS BOTH
   TF 2 
   same field list 
   ON TABLE SAVE AS BOTH 

2. TF 1
   PRINT field list
   MORE 
   FILE 2
   ON TABLE HOLD AS BOTH 
   END 

The second method has the drawback that if a field is not common to both of the files then you have to create defines. This is simple enough for advanced users but can be a bind for the end user.

To this end I have created a utility which anyone is free to use on the condition they post any improvements in the interests of collaborative development!

-****************************************************************************************
-* UNION.FEX Takes 2 files (HOLD1 and HOLD2) and concatenates then aligned similar named
-*           columns into a third file HOLD3.
-* Example   EX UNION HOLD1=SEATS, HOLD2=COST, HOLD3=CARCOMB
-* Notes
-* 1. Rename columns in your hold files by using field AS newname
-*    with ON TABLE SET ASNAMES ON also on ON TABLE SET HOLDLIST PRINTONLY is useful.
-* 2. Like named columns must have exactly the same format. A possible modification could
-*    be to reformat the input fields to a common output eg longest alpha format.
-* 3. Format of field might be changed to missing on - again could be future improvement.
-* Ver   By        Date         Modification
-* 1.01  hammo1j   12-JUL-2007  Originally written
-****************************************************************************************
-TYPE ================================================================================ UNION utility starting ...
-SET &LCHOLD1 = &HOLD1 ;
-SET &LCHOLD1 = LOCASE(&HOLD1.LENGTH,ASIS(&HOLD1),&LCHOLD1) ;

-SET &LCHOLD2 = &HOLD2 ;
-SET &LCHOLD2 = LOCASE(&HOLD2.LENGTH,ASIS(&HOLD2),&LCHOLD2) ;

MATCH FILE SYSCOLUM
SUM USAGE AS USAGE1
BY NAME
WHERE TBNAME EQ '&LCHOLD1'
RUN
FILE SYSCOLUM
SUM USAGE AS USAGE2
BY NAME
WHERE TBNAME EQ '&LCHOLD2'
AFTER MATCH HOLD AS UNIONA OLD-OR-NEW
END
-RUN
CMD DEL UNIONB.FEX
FILEDEF UNIONB DISK UNIONB.FEX ( APPEND
-RUN
-* define dummy fields in 2 not in 1
-WRITE UNIONB DEFINE FILE &HOLD1 ADD
DEFINE FILE UNIONA
EXTRAFLD1/A200 = NAME | '/' | USAGE2 | ' MISSING ON = ; ' ;
END
TABLE FILE UNIONA
PRINT EXTRAFLD1
WHERE USAGE1 EQ MISSING
ON TABLE SAVE AS UNIONB
END
-RUN
-WRITE UNIONB END
-* define dummy fields in 1 not in 2
-WRITE UNIONB DEFINE FILE &HOLD2 ADD
DEFINE FILE UNIONA
EXTRAFLD2/A200 = NAME | '/' | USAGE1 | ' MISSING ON = ; ' ;
END
TABLE FILE UNIONA
PRINT EXTRAFLD2
WHERE USAGE2 EQ MISSING
ON TABLE SAVE AS UNIONB
END
-RUN
-WRITE UNIONB END
-* now concatenate the files using MORE facility
-WRITE UNIONB TABLE FILE &HOLD1
-WRITE UNIONB PRINT
TABLE FILE UNIONA
PRINT NAME
ON TABLE SAVE AS UNIONB
END
-RUN
-WRITE UNIONB ON TABLE HOLD AS &HOLD3
-WRITE UNIONB MORE
-WRITE UNIONB FILE &HOLD2
-WRITE UNIONB END
-CLOSE UNIONB
EX UNIONB.FEX
-RUN
-TYPE ================================================================================ ... UNION utility finished



Here is an example of code that uses the facility.

-* File union.fex
TABLE FILE CAR
PRINT
     MODEL
     SEATS
ON TABLE HOLD AS SEATS
END
-RUN
-* File union.fex
TABLE FILE CAR
PRINT
     MODEL
     RETAIL_COST
     BHP
ON TABLE HOLD AS COST
END
-RUN
EX UNION HOLD1=SEATS, HOLD2=COST, HOLD3=CARCOMB
-RUN
TABLE FILE CARCOMB
PRINT *
END
-EXIT



Hope this may be of use.

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



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report 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     Utility to perform SQL UNION in WebFOCUS

Copyright © 1996-2020 Information Builders