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] Not IN Sub-query

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Not IN Sub-query
 Login/Join
 
Gold member
posted
Good morning,

I am trying to write a query that will compare results to a sub-query. In sql I would say where pidm NOT IN (subquery). How would I do this in web focus. Would the subquery be in the same procedure or would I create a separate procedure and have it look at an external file list? Is this subquery possible in WebFOCUS?

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


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Expert
posted Hide Post
You could do what you call the sub-query in the same procedure, hold the results FORMAT FOCUS INDEX keyfield. Then join the results of the primary query to it.

Or if you are using the results of the subquery to screen the results of the primary query, you can use the WHERE IN FILE syntax to use the results from the subquery to select from the primary table and then join.

For better or worse, there are lots of methods depending on exactly what you want to do.

Maybe you should post your SQL.


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
Gold member
posted Hide Post
(Attached is the code that I'm trying to write in focus. Look at the Where pidm_key NOT IN the the clause in parenthesis. I know it's not right...I don't know FOCUS language so I'm guessing.

TABLE FILE INFOHOLD
SUM
PIDM_KEY NOPRINT
ID
LAST_NAME
FIRST_NAME
MIDDLE_INITIAL
STYP_CODE
TOTAL_BILLING_HOURS
COMPUTE Amountpaid/D12.2 = RPRATRM_ACCEPT_AMT + TBRACCD_AMOUNT + TBRMEMO_AMOUNT;
AS 'Amount,Paid'
TBRACCD_BALANCE AS 'Account,Balance'
BY LAST_NAME NOPRINT
BY FIRST_NAME NOPRINT
BY MIDDLE_INITIAL NOPRINT
WHERE PIDM_KEY NOT IN (TABLE FILE AS_ADMISSIONS_APPLICANT
SUM
PIDM_KEY
WHERE TERM_CODE_KEY EQ '200809';
WHERE APDC_CODE1 EQ 'AC' OR 'PC';
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE HOLD AS NWSTHOLD FORMAT FOCUS INDEX 'PIDM_KEY'
ON TABLE SET HTMLCSS ON)
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT &WFFMT.(,,,,,).Select type of display output.
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
GRID=OFF,
FONT='ARIAL',
SIZE=9,
$
TYPE=TITLE,
STYLE=BOLD,
$
TYPE=TABHEADING,
SIZE=12,
STYLE=BOLD,
$
TYPE=TABFOOTING,
SIZE=12,
STYLE=BOLD,
$
TYPE=HEADING,
SIZE=12,
STYLE=BOLD,
$
TYPE=HEADING,
LINE=1,
JUSTIFY=CENTER,
$
TYPE=FOOTING,
SIZE=12,
STYLE=BOLD,
$
TYPE=SUBHEAD,
SIZE=10,
STYLE=BOLD,
$
TYPE=SUBFOOT,
SIZE=10,
STYLE=BOLD,
$
TYPE=SUBTOTAL,
BACKCOLOR=RGB(210 210 210),
$
TYPE=ACROSSVALUE,
SIZE=9,
$
TYPE=ACROSSTITLE,
STYLE=BOLD,
$
TYPE=GRANDTOTAL,
BACKCOLOR=RGB(210 210 210),
STYLE=BOLD,
$
ENDSTYLE
END


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Guru
posted Hide Post
One of the things you can do is first run the sub-query and hold the output (format focus index on the join field), then to a left_outer join from the main file to the hold file, and use a where a field from the hold file is missing.


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
 
Posts: 398 | Registered: February 04, 2008Report This Post
Gold member
posted Hide Post
RSquared...I just tried your suggestion but only got back 0 persons. I know I'm close....could you look at the code?

JOIN
LEFT_OUTER STINFOHOLD.SEG01.PIDM_KEY IN STINFOHOLD TO UNIQUE
NWSTHOLD.SEG01.PIDM_KEY IN NWSTHOLD AS J2
END
TABLE FILE STINFOHOLD
SUM
ID
LAST_NAME
FIRST_NAME
MIDDLE_INITIAL
STYP_CODE
TOTAL_BILLING_HOURS
BY PIDM_KEY
HEADING
""
FOOTING
""
WHERE PIDM_KEY EQ MISSING;
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Virtuoso
posted Hide Post
quote:
WHERE PIDM_KEY EQ MISSING


You probably need to say WHERE NWSTHOLD.PIDM_KEY EQ MISSING;

Just using the PIDM_KEY would find the first field in the joined structure which would be the one in stinfohold. If that field value is null (missing), then the join wouldn't work at all. So if you want to test the field in the cross-referenced file, use the filename qualifier.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Virtuoso
posted Hide Post
or TAG your joins and use TAGNAME.FIELDNAME. Same thing basically.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Gold member
posted Hide Post
I'm trying to get all the pidms from STINFOHOLD that are not in NWSTHOLD. I think GinnyJakes described it a little when he said "Or if you are using the results of the subquery to screen the results of the primary query, you can use the WHERE IN FILE syntax to use the results from the subquery to select from the primary table and then join."

So do I use a WHERE NOT IN FILE? I used the WHERE NWSTHOLD.PIDM_KEY EQ MISSING, but I got 0 returns. The code is below:

TABLE FILE STINFOHOLD
SUM
ID
LAST_NAME
FIRST_NAME
MIDDLE_INITIAL
STYP_CODE
TOTAL_BILLING_HOURS
BY PIDM_KEY
HEADING
""
FOOTING
""
WHERE NWSTHOLD.PIDM_KEY EQ MISSING;
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Gold member
posted Hide Post
Just saw your comment Darin I looked at my join syntax and it looked tagged already.

JOIN
LEFT_OUTER STINFOHOLD.SEG01.PIDM_KEY IN STINFOHOLD TO UNIQUE
NWSTHOLD.SEG01.PIDM_KEY IN NWSTHOLD AS J2
END

So I changed the Where clause to:
WHERE NWSTHOLD.SEG01.PIDM_KEY EQ MISSING;

but I still got zero.


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Expert
posted Hide Post
I'm not a 'he'.


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
Gold member
posted Hide Post
Ginny...I am so sorry.....'girl'....won't happen again Winky


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Expert
posted Hide Post
That's ok. I've just never run across a guy in my whole life named Ginny (aka Virginia). Big Grin


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
Guru
posted Hide Post
Try using another field, not the field that you join on.


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
 
Posts: 398 | Registered: February 04, 2008Report This Post
Gold member
posted Hide Post
Ginny...it was a typo....I could have sworn my finger hit the 's' before the 'h'. Big Grin


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Virtuoso
posted Hide Post
Clarification about tags:

JOIN LEFT_OUTER
STINFOHOLD.SEG01.PIDM_KEY IN STINFOHOLD
TO UNIQUE
NWSTHOLD.SEG01.PIDM_KEY IN NWSTHOLD
AS J2
END

You coded a join-name (J2), but no tag-name. They are two separate parts of the syntax:

JOIN field1 IN file1 TO field2 IN file2 TAG tag2 AS joinid

That allows you to use either "joinid" (no dot) or "tagvalue." as an identifying prefix.

The tag is directly associated with the file (newer syntax allows tagging both files, which can be usefull when joining a file to itself),
while the joinid labels the join statement
(although the effect is similar -- the joinid used as a fieldname modifier refers to the fields made accessible by the join, viz. those in the second file).

Inserting
?FF STINFOHOLD
after the JOIN will display the filenames and aliases, with sufficient qualification to make the reference unambiguous.

- - - - -

Back to selection. "WHERE NWSTHOLD.SEG01.PIDM_KEY EQ MISSING;"

How is PIDM_KEY declared in the NWSTHOLD master? If it doesn't have MISSING=ON, the result will never be MISSING (if no matching row exists, it will have a default values of zero (or blank).

But, assuming STINFOHOLD.SEG01.PIDM_KEY always has a non-zero (or non-blank) value, you can use
WHERE STINFOHOLD.SEG01.PIDM_KEY NE NWSTHOLD.SEG01.PIDM_KEY ;
to select the instances for which the JOIN UNIQUE navigation came up emptyhanded.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Gold member
posted Hide Post
I think I may have confused everyone....let me start again.

The unique
identifier in both files is the pidm_key. I want to pull all the pidms from the
main file that do not exist in the cross ref. file. Sorry 'not in' suggested that
there is some value that i want to exclude. I should have said NOT EXIST. Any new ideas for me now.


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Gold member
posted Hide Post
OMG!!! I got something back. I used the code suggest by j.g.: STINFOHOLD.SEG01.PIDM_KEY NE NWSTHOLD.SEG01.PIDM_KEY

Thank you so much Jack Gross.


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Virtuoso
posted Hide Post
Kitten,
There are basically 2 ways to do this.
1.
MATCH FILE MAIN
[here you use the fields you want to extract from the MAIN file and the screening conditions]
BY PIDM_KEY
RUN
FILE XREF
....
BY PIDM_KEY
AFTER MATCH HOLD OLD-NOT-NEW
END

2.
SET ALL=PASS
JOIN PIDM_KEY IN MAIN TO ALL PIDM_KEY IN XREF AS J
TABLE FILE MAIN
[here some impossible condition on the the XREF file]


You will get all the records in MAIN that do not have a corresponding in XREF


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Gold member
posted Hide Post
Thanks for the suggestion Danny...I will also try the match file.


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
 
Posts: 91 | Registered: May 15, 2008Report This Post
Member
posted Hide Post
kitten,

We had a similar issue, and discovered that the NOT goes with the WHERE and not with IN FILE. Using your code as an example, the syntax should be:

WHERE NOT PIDM_KEY IN FILE filename

Where the filename is the name used in a FILEDEF to hold the values you want it include/exclude in your query.

Below is an example using CAR file. The first thing I did was create a procedure that dynamically creates a list of Countries containing the letter 'E', and putting them in a ALPHA formatted HOLD file called CTRYLIST. Then, I run a second procedure, using the WHERE NOT syntax against the CTRYLIST hold file.

Sorry to come so late to the dance. Hope this is still relevent.

Rich

APP FI CTRYLIST DISK baseapp/CTRYLIST.ftm
-RUN

TABLE FILE CAR
SUM DEALER_COST NOPRINT
BY COUNTRY AS ' '
WHERE COUNTRY CONTAINS 'E'
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE HOLD AS CTRYLIST FORMAT ALPHA
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
ENDSTYLE
END

TABLE FILE CAR
SUM
DEALER_COST
RETAIL_COST
BY COUNTRY
BY CAR
BY MODEL

WHERE NOT COUNTRY IN FILE CTRYLIST;

ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
GRID=OFF,
FONT='ARIAL',
SIZE=9,
$
ENDSTYLE
END
 
Posts: 5 | Registered: June 09, 2004Report This Post
Gold member
posted Hide Post
Thanks for this Rich! It certainly helps me Smiler

Jinx.


7.6.11
Windows
HTML, PDF, Excel etc
DevStudio/Webfocus/Focus IBM
SQL Server 2000 / 2008
DB2
 
Posts: 78 | Location: UK | Registered: February 07, 2008Report 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] Not IN Sub-query

Copyright © 1996-2020 Information Builders