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     how to use sql in focus????

Read-Only Read-Only Topic
Go
Search
Notify
Tools
how to use sql in focus????
 Login/Join
 
<beginner>
posted
Dear all;

I try to do the following:

there exist 2 tables in database

TABLE 1:
STUDENT GROUP PHONE_NO
A 1 333-4567
B 2 333-4578
C 1 333-4589

TABLE 2:
STUDENT GROUP MOBILE_NO
A 1 999-8888
B 2 999-6541
C 1 999-7777

using FOCUS
I'd like to show the following in the report:

STUDENT MOBILE
A 999-8888
B 999-7777

I wrote down :

SET SQLENGINE=SQLORA
SQL PREPARE FOR TEMPTABLE
SELECT A.STUDENT,
DECODE(A.GROUP,1,B.MOBILE_NO,A.PHONE_NO)
FROM TABLE1 A, TABLE2 B
WHERE A.STUDENT=B.STUDENT AND
A.GROUP=B.GROUP
END
-RUN

TABLE FILE TEMPTABLE
PRINT *
END
-RUN

It didn't print anything in the report. Am I missing anything or is it the right way to do it?

Please help ASAP,

new focuser
 
Report This Post
<Grzegorz>
posted
If you would like to use prepared SQL statement you can use the following syntax (I changed GROUP column name to GROUP_ID because my Oracle RDBMS does not like GROUP as a column name):

SET SQLENGINE=SQLORA
-*
SQL PREPARE STUDENT_QUERY FROM
SELECT A.STUDENT,
DECODE(A.GROUP_ID,1,B.MOBILE_NO,A.PHONE_NO) MOBILE
FROM TABLE1 A, TABLE2 B
WHERE A.STUDENT=B.STUDENT AND
A.GROUP_ID=B.GROUP_ID
END
-*
SQL EXECUTE STUDENT_QUERY;
TABLE
ON TABLE HOLD
END
-RUN
TABLE FILE HOLD
PRINT *
END
If you do not want to use prepared statement, there is even simpler syntax:

SQL SQLORA
SELECT A.STUDENT,
DECODE(A.GROUP_ID,1,B.MOBILE_NO,A.PHONE_NO) MOBILE
FROM TABLE1 A, TABLE2 B
WHERE A.STUDENT=B.STUDENT AND
A.GROUP_ID=B.GROUP_ID;
END
or

SQL SQLORA
SELECT A.STUDENT,
DECODE(A.GROUP_ID,1,B.MOBILE_NO,A.PHONE_NO) MOBILE
FROM TABLE1 A, TABLE2 B
WHERE A.STUDENT=B.STUDENT AND
A.GROUP_ID=B.GROUP_ID;
TABLE
ON TABLE HOLD
END
TABLE FILE HOLD
-* Use the FOCUS syntax, here:
-* ...
ENDThe "FOCUS-SQL" syntax is described and explained within the manual: "IWay SQL Reference Version 5 Release 2.0".

Hope this helps
Grzegorz

This message has been edited. Last edited by: <Mabel>,
 
Report This Post
<beginner>
posted
Thank you very much for you help.
I have further questions.
What if I want the following:

STUDENT GROUP NUMBER
A 1 999-8888
B 2 333-4578
C 1 999-7777

note: if group = 1, show mobile number
if group = 2, shoue phone number

Please help me Frowner
 
Report This Post
<Grzegorz>
posted
The following query is just doing it (using Oracle syntax):

SQL SQLORA
SELECT A.STUDENT, A.GROUP_ID,
DECODE(A.GROUP_ID,
1, B.MOBILE_NO,
2, A.PHONE_NO) PH_NUMBER
FROM TABLE1 A, TABLE2 B
WHERE A.STUDENT=B.STUDENT AND
A.GROUP_ID=B.GROUP_ID;
END
The equivalent syntax in FOCUS is (at least one of the possibilities):

SQL SQLORA
SELECT A.STUDENT, A.GROUP_ID,
B.MOBILE_NO, A.PHONE_NO
FROM TABLE1 A, TABLE2 B
WHERE A.STUDENT=B.STUDENT AND
A.GROUP_ID=B.GROUP_ID;
TABLE
ON TABLE HOLD AS STUDENTS
END
-*
DEFINE FILE STUDENTS
NUMBER/A9 = IF GROUP_ID EQ '1' THEN MOBILE_NO
ELSE PHONE_NO;
END
-*
TABLE FILE STUDENTS
PRINT NUMBER
BY STUDENT
BY GROUP_ID AS 'GROUP'
END
You can, of course, create WF synonym with joined TABLE1 and TABLE2, and the Oracle query will be generated "in the background".

Hope this helps
Grzegorz

This message has been edited. Last edited by: <Mabel>,
 
Report 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     how to use sql in focus????

Copyright © 1996-2020 Information Builders