Your SlideShare is downloading. ×
0
FOCUS to DB2 <ul><li>By:  Meadow Heath </li></ul>
FOCUS to DB2 <ul><li>Define DB2 table to FOCUS </li></ul><ul><li>How FOCUS processes a DB2 request </li></ul><ul><li>FOCUS...
Define DB2 table to FOCUS <ul><li>CAR Master File Description </li></ul><ul><li>CAR Access File Description </li></ul>
CAR MFD FILE=CAR  ,SUFFIX=SQLDS ,$  SEGNAME=CAR  ,SEGTYPE=S0 ,$  FIELD=COUNTRY  ,COUNTRY  ,A10  ,A10  ,MISSING=OFF,$ FIELD...
CAR ACCESS File SEGNAME= CAR  ,TABLENAME= '”IBI&quot;.”CAR&quot;'  ,KEYS= 0 ,WRITE= YES ,$  SEGMENT  associates the Master...
FOCUS to DB2 Processing <ul><li>High level diagram of process </li></ul><ul><ul><li>FOCUS Request </li></ul></ul><ul><ul><...
FOCUS Request Programmer submits a FOCEXEC: TABLE FILE CAR  PRINT CAR  MODEL  DEALER_COST  RETAIL_COST  END
High Level Diagram of Process FOCUS (Processing) DB2 Interface (creates SQL) db2 request focexec <ul><li>Programmer execut...
DB2 Interface DB2 Interface translates the FOCEXEC into SQL code: TABLE FILE CAR  PRINT CAR  MODEL  DEALER_COST  RETAIL_CO...
High Level Diagram of Process FOCUS (Processing) DB2 Interface (creates SQL) RDBMS Table Table db2 request focexec db2 res...
Results FOCEXEC: TABLE FILE CAR  PRINT CAR  MODEL  DEALER_COST  RETAIL_COST  END   SQL: SELECT T1.CAR,T1.MODEL,T1.DCOST,T2...
FOCUS to DB2 Efficiencies <ul><li>Sorting Data </li></ul><ul><li>Selection Criteria </li></ul><ul><li>Data Calculations </...
Sorting Data <ul><li>Sorting Defined field  </li></ul><ul><li>Sorting on DB2 field  </li></ul>
Sorting on Define field FOCEXEC: DEFINE FILE CAR  NEW_NAME/A3 =EDIT(MODEL,'999');  END  TABLE FILE CAR  PRINT CAR  BY NEW_...
Sorting on DB2 field FOCEXEC: DEFINE FILE CAR  NEW_NAME/A3 =EDIT(MODEL,'999');  END  TABLE FILE CAR  PRINT NEW_NAME  CAR  ...
Selection Criteria <ul><li>Selecting from fields created with User-written subroutines  </li></ul><ul><li>Selecting from f...
Selecting from fields created with User-written subroutines FOCEXEC: DEFINE FILE CAR  NEW_NAME/A3 =SUBSTR(24,MODEL,1,3,3,N...
Selecting from fields created with Edit Feature FOCEXEC: DEFINE FILE CAR  NEW_NAME/A3 =EDIT(MODEL,'999');  END  TABLE FILE...
Data Calculations <ul><li>Calculations in a Compute </li></ul><ul><li>Calculations in a Define  </li></ul>
Calculations with Compute FOCEXEC: TABLE FILE CAR  SUM  COMPUTE NEW_AMT/D7 =RETAIL_COST - DEALER_COST;  BY CAR  END  SQL: ...
Calculations in Define FOCEXEC: DEFINE FILE CAR  NEW_AMT/D7 =RETAIL_COST - DEALER_COST;  END  TABLE FILE CAR  SUM  NEW_AMT...
How to determine efficiency <ul><li>Test efficiency with FSTRACE4 </li></ul><ul><li>FSTRACE4 shows the translation into SQ...
Summary <ul><li>Define DB2 table to FOCUS in the Master File Description and Access File Description </li></ul>
Define the DB2 table to FOCUS  Master File Description (MASTER) FILE=CAR  ,SUFFIX=SQLDS ,$  SEGNAME=CAR  ,SEGTYPE=S0 ,$  F...
Summary <ul><li>Define DB2 table to FOCUS in the Master File Description and Access File Description </li></ul><ul><li>The...
High Level Diagram of Process FOCUS (Processing) DB2 Interface (creates SQL) RDBMS Table Table db2 request focexec db2 res...
Summary <ul><li>Define DB2 table to FOCUS in the Master File Description and Access File Description </li></ul><ul><li>The...
DB2 should do most of the work <ul><li>DB2 Translator should be able to convert your data processing into SQL code when: <...
Questions
Upcoming SlideShare
Loading in...5
×

Focus/DB2 interface

386

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
386
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Focus/DB2 interface"

  1. 1. FOCUS to DB2 <ul><li>By: Meadow Heath </li></ul>
  2. 2. FOCUS to DB2 <ul><li>Define DB2 table to FOCUS </li></ul><ul><li>How FOCUS processes a DB2 request </li></ul><ul><li>FOCUS to DB2 Efficiencies </li></ul>
  3. 3. Define DB2 table to FOCUS <ul><li>CAR Master File Description </li></ul><ul><li>CAR Access File Description </li></ul>
  4. 4. CAR MFD FILE=CAR ,SUFFIX=SQLDS ,$ SEGNAME=CAR ,SEGTYPE=S0 ,$ FIELD=COUNTRY ,COUNTRY ,A10 ,A10 ,MISSING=OFF,$ FIELD=CAR ,CARS ,A16 ,A16 ,MISSING=OFF,$ FIELD=MODEL ,MODEL ,A24 ,A24 ,MISSING=OFF,$ FIELD=BODYTYPE ,TYPE ,A12 ,A12 ,MISSING=OFF,$ FIELD=SEATS ,SEAT ,I3 ,I4 ,MISSING=OFF,$ FIELD=DEALER_COST ,DCOST ,D7 ,D8 ,MISSING=OFF,$ FIELD=RETAIL_COST ,RCOST ,D7 ,D8 ,MISSING=OFF,$ FIELD=SALES ,UNITS ,I6 ,I4 ,MISSING=OFF,$ FIELD=LENGTH ,LEN ,D5 ,D5 ,MISSING=OFF,$ FIELD=WIDTH ,WIDTH ,D5 ,D5 ,MISSING=OFF,$ FIELD=HEIGHT ,HEIGHT ,A2 ,A2 ,MISSING=OFF,$ FIELD=WHEELBASE ,BASE ,D6.1 ,D8 ,MISSING=OFF,$ FIELD=FUEL_CAP ,FUEL ,D6.1 ,D8 ,MISSING=OFF,$ FIELD=BHP ,POWER ,D6 ,D6 ,MISSING=OFF,$ FIELD=RPM ,RPM ,I5 ,I4 ,MISSING=OFF,$ ALIAS column should be the same name as the column name defined to the DB2 table MISSING = OFF default value and should be used with NOT NULL columns in DB2 MISSING = ON displays the FOCUS NODATA value for missing data ACTUAL format is converted from the SQL Datatype: CHAR(n)=An, VARCHAR(n)=An, SMALLINT=I4, INTEGER=I4, DECIMAL=P, REAL=F4, FLOAT=D8,DATE=DATE . . .
  5. 5. CAR ACCESS File SEGNAME= CAR ,TABLENAME= '”IBI&quot;.”CAR&quot;' ,KEYS= 0 ,WRITE= YES ,$ SEGMENT associates the Master File with table it describes WRITE=YES (default) specifies read and write access using MODIFY and MAINTAIN WRITE=NO Read-only access using MODIFY and MAINTAIN PRIMARY KEY must be defined (if there is one) KYFLD and IXFLD would be included for multi-table structures -- used for dynamic JOINs. ALLOCATION for the Access File is done in the FOCSQL library DYNAM ALLOC FILE FOCSQL DA {node}.FOCSQL.DATA
  6. 6. FOCUS to DB2 Processing <ul><li>High level diagram of process </li></ul><ul><ul><li>FOCUS Request </li></ul></ul><ul><ul><li>DB2 Interface </li></ul></ul><ul><ul><li>Results </li></ul></ul>
  7. 7. FOCUS Request Programmer submits a FOCEXEC: TABLE FILE CAR PRINT CAR MODEL DEALER_COST RETAIL_COST END
  8. 8. High Level Diagram of Process FOCUS (Processing) DB2 Interface (creates SQL) db2 request focexec <ul><li>Programmer executes FOCEXEC </li></ul><ul><li>FOCUS parses request and passes to DB2 Interface </li></ul>
  9. 9. DB2 Interface DB2 Interface translates the FOCEXEC into SQL code: TABLE FILE CAR PRINT CAR MODEL DEALER_COST RETAIL_COST END SQL: SELECT T1.CAR,T1.MODEL,T1.DCOST,T1.RCOST FROM CAR T1 FOR FETCH ONLY;
  10. 10. High Level Diagram of Process FOCUS (Processing) DB2 Interface (creates SQL) RDBMS Table Table db2 request focexec db2 results s q l d a t a <ul><li>FOCUS parses request and passes to DB2 Interface </li></ul><ul><li>DB2 Interface builds SQL & passes to RDBMS </li></ul><ul><li>RDBMS retrieves data from DB2 table(s) </li></ul><ul><li>RDBMS returns data to DB2 Interface </li></ul><ul><li>FOCUS completes any process not handled by DB2 </li></ul><ul><li>Programmer executes FOCEXEC </li></ul>results <ul><li>Results returned to programmer </li></ul>
  11. 11. Results FOCEXEC: TABLE FILE CAR PRINT CAR MODEL DEALER_COST RETAIL_COST END SQL: SELECT T1.CAR,T1.MODEL,T1.DCOST,T2RCOST FROM CAR T1 FOR FETCH ONLY; RESULTS: CAR MODEL DEALER_COST RETAIL_COST --- ----- ----------- ----------- JAGUAR V12XKE AUTO 7,427 8,878 JAGUAR XJ12L AUTO 11,194 13,491 JENSEN INTERCEPTOR III 14,940 17,850 DATSUN B210 2 DOOR AUTO 2,626 3,139 MASERATI DORA 2 DOOR 25,000 31,500 . . . PEUGEOT 504 4 DOOR 4,631 5,610
  12. 12. FOCUS to DB2 Efficiencies <ul><li>Sorting Data </li></ul><ul><li>Selection Criteria </li></ul><ul><li>Data Calculations </li></ul><ul><li>How to determine efficiency </li></ul>
  13. 13. Sorting Data <ul><li>Sorting Defined field </li></ul><ul><li>Sorting on DB2 field </li></ul>
  14. 14. Sorting on Define field FOCEXEC: DEFINE FILE CAR NEW_NAME/A3 =EDIT(MODEL,'999'); END TABLE FILE CAR PRINT CAR BY NEW_NAME END SQL: SELECT T1.CAR,T1.MODEL FROM CAR T1 FOR FETCH ONLY; RESULTS: NEW_NAME CAR -------- --- B21 DATSUN COR TOYOTA DOR MASERATI . . . 530 BMW NOTICE: Sort statement is not passed to DB2; FOCUS will have to sort the data before sending results back to the programmer.
  15. 15. Sorting on DB2 field FOCEXEC: DEFINE FILE CAR NEW_NAME/A3 =EDIT(MODEL,'999'); END TABLE FILE CAR PRINT NEW_NAME CAR BY MODEL NOPRINT END SQL: SELECT T1.CAR,T1.MODEL FROM CAR T1 ORDER BY T1.MODEL FOR FETCH ONLY; RESULTS: NEW_NAME CAR -------- --- B21 DATSUN COR TOYOTA DOR MASERATI . . . 530 BMW NOTICE: ORDER BY statement is added to the SQL passed to DB2. DB2 will sort the data before returning results to FOCUS.
  16. 16. Selection Criteria <ul><li>Selecting from fields created with User-written subroutines </li></ul><ul><li>Selecting from fields created with Edit feature </li></ul>
  17. 17. Selecting from fields created with User-written subroutines FOCEXEC: DEFINE FILE CAR NEW_NAME/A3 =SUBSTR(24,MODEL,1,3,3,NEW_NAME); END TABLE FILE CAR PRINT CAR BY NEW_NAME WHERE NEW_NAME LT 'C' END SQL: SELECT T1.CAR,T1.MODEL FROM CAR T1 FOR FETCH ONLY; RESULTS: NEW_NAME CAR -------- --- B21 DATSUN NOTICE: No selection criteria is passed to DB2; therefore, DB2 will pass all the data back, and FOCUS will have to complete the request.
  18. 18. Selecting from fields created with Edit Feature FOCEXEC: DEFINE FILE CAR NEW_NAME/A3 =EDIT(MODEL,'999'); END TABLE FILE CAR PRINT CAR BY NEW_NAME WHERE NEW_NAME LT 'C' END SQL: SELECT T1.CAR,T1.MODEL FROM CAR T1 WHERE ((SUBSTR(T1.MODEL,1,3)) < ‘C’) FOR FETCH ONLY; RESULTS: NEW_NAME CAR -------- --- B21 DATSUN NOTICE: WHERE NEW_NAME LT ‘C’ is translated by the DB2 Interface.
  19. 19. Data Calculations <ul><li>Calculations in a Compute </li></ul><ul><li>Calculations in a Define </li></ul>
  20. 20. Calculations with Compute FOCEXEC: TABLE FILE CAR SUM COMPUTE NEW_AMT/D7 =RETAIL_COST - DEALER_COST; BY CAR END SQL: SELECT T1.CAR,SUM(T1.DCOST),SUM(T1.RCOST) FROM CAR T1 GROUP BY T1.CAR ORDER T1.CAR FOR FETCH ONLY; RESULTS: CAR NEW_AMT --- ------- ALFA ROMEO 3,330 AUDI 907 BMW 9,262 DATSUN 513 JAGUAR 3,748 JENSEN 2,910 MASERATI 6,500 PEUGEOT 979 TOYOTA 453 TRIUMPH 808 NOTICE: NEW_AMT is not translated by the DB2 Interface; therefore, FOCUS does this calculation once all the data is retrieved from DB2.
  21. 21. Calculations in Define FOCEXEC: DEFINE FILE CAR NEW_AMT/D7 =RETAIL_COST - DEALER_COST; END TABLE FILE CAR SUM NEW_AMT BY CAR END SQL: SELECT T1.CAR, SUM((T1.RCOST - T1.DCOST)) FROM CAR T1 GROUP BY T1.CAR ORDER BY T1.CAR FOR FETCH ONLY; RESULTS: CAR NEW_AMT --- ------- ALFA ROMEO 3,330 AUDI 907 BMW 9,262 . . TRIUMPH 808 NOTICE: NEW_AMT is passed to DB2 to do the calculation.
  22. 22. How to determine efficiency <ul><li>Test efficiency with FSTRACE4 </li></ul><ul><li>FSTRACE4 shows the translation into SQL code </li></ul><ul><li>1) DYNAM ALLOC FILE FSTRACE4 * </li></ul><ul><li>(OR ALLOCATE TO A FILE) </li></ul><ul><li>2) Execute your FOCEXEC </li></ul><ul><li>3) Review FSTRACE4 to verify that the DB2 Translator converted your FOCEXEC into SQL code where possible </li></ul>
  23. 23. Summary <ul><li>Define DB2 table to FOCUS in the Master File Description and Access File Description </li></ul>
  24. 24. Define the DB2 table to FOCUS Master File Description (MASTER) FILE=CAR ,SUFFIX=SQLDS ,$ SEGNAME=CAR ,SEGTYPE=S0 ,$ FIELD=COUNTRY ,COUNTRY ,A10 ,A10 ,MISSING=OFF,$ FIELD=CAR ,CARS ,A16 ,A16 ,MISSING=OFF,$ FIELD=MODEL ,MODEL ,A24 ,A24 ,MISSING=OFF,$ . . . FIELD=RPM ,RPM ,I5 ,I4 ,MISSING=OFF,$ Access File Description (FOCSQL) SEGNAME= CAR ,TABLENAME= '”IBI&quot;.”CAR&quot;' ,KEYS= 0 ,WRITE= YES ,$
  25. 25. Summary <ul><li>Define DB2 table to FOCUS in the Master File Description and Access File Description </li></ul><ul><li>The DB2 Translator translates the FOCEXEC into SQL code to be passed to the RDBMS </li></ul>
  26. 26. High Level Diagram of Process FOCUS (Processing) DB2 Interface (creates SQL) RDBMS Table Table db2 request focexec db2 results s q l d a t a <ul><li>FOCUS parses request and passes to DB2 Interface </li></ul><ul><li>DB2 Interface builds SQL & passes to RDBMS </li></ul><ul><li>RDBMS retrieves data from DB2 table(s) </li></ul><ul><li>RDBMS returns data to DB2 Interface </li></ul><ul><li>FOCUS completes any process not handled by DB2 </li></ul><ul><li>Programmer executes FOCEXEC </li></ul>results <ul><li>Results returned to programmer </li></ul>
  27. 27. Summary <ul><li>Define DB2 table to FOCUS in the Master File Description and Access File Description </li></ul><ul><li>The DB2 Translator translates the FOCEXEC into SQL code to be passed to the RDBMS </li></ul><ul><li>Write your FOCEXEC to be more efficient by making DB2 do most of the work </li></ul>
  28. 28. DB2 should do most of the work <ul><li>DB2 Translator should be able to convert your data processing into SQL code when: </li></ul><ul><ul><li>Sorting Data </li></ul></ul><ul><ul><li>Selection Criteria </li></ul></ul><ul><ul><li>Data Calculations </li></ul></ul><ul><li>Test efficiency with FSTRACE4 </li></ul>
  29. 29. Questions
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×