FOCUS to DB2 By: Meadow Heath.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Advertisements

Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Structured Query Language (SQL)
Data Definition and Integrity Constraints
Sorting Rows. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –Construct a query to sort a results set in ascending.
Information Systems Today: Managing in the Digital World
Database Performance Tuning and Query Optimization
Organisation Of Data (1) Database Theory
A Guide to Oracle9i1 Creating and Modifying Database Tables Chapter 2.
Chapter 7 Working with Databases and MySQL
Session 2Introduction to Database Technology Data Types and Table Creation.
Yong Choi School of Business CSU, Bakersfield
State of Connecticut Core-CT Project Query 8 hrs Updated 6/06/2006.
CC SQL Utilities.
SQL - Subqueries and Schema Chapter 3.4 V3.0 Napier University Dr Gordon Russell.
Database Chapters.
Chapter 8 Improving the User Interface
Relational Efficiencies Renee Teatro June Relational Efficiencies Agenda  Optimization Overview  JOIN Scenarios  Sort Scenarios  Aggregation.
Copyright 2007, Information Builders. Slide 1 Relational Efficiencies: Part II Overview and JOIN / Sort Scenarios Renee Teatro Information Builders.
Copyright 2007, Information Builders. Slide 1 Walter Brengel Information Builders New Jersey User Forum – June 2008 FOCUS to SQL DeMystified.
McGyver for Dynamic Subtotals/Subfoots Presented by David Smith of Brinker International.
Day 3 - Basics of MySQL What is MySQL What is MySQL How to make basic tables How to make basic tables Simple MySQL commands. Simple MySQL commands.
Fundamentals, Design, and Implementation, 9/e Chapter 12 ODBC, OLE DB, ADO, and ASP.
Computer Science 1620 Programming & Problem Solving.
Databases Tutorial 2 Further Select Statements. Objectives for Week Data types Sort retrieved data Formatting output.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
SQL Query Extras MIS 433. Rerunning the last Query n Type the forward slash “/” to rerun the last query that was entered.
State of Connecticut Core-CT Project Query 4 hrs Updated 1/21/2011.
MS Access: Database Concepts Instructor: Vicki Weidler.
Oracle Data Definition Language (DDL)
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Rationale Aspiring Database Developers should be able to efficiently query and maintain databases. This module will help students learn the Structured.
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
PowerBuilder Online Courses - by Prasad Bodepudi
Object Persistence Design Chapter 13. Key Definitions Object persistence involves the selection of a storage format and optimization for performance.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
Database Management Systems.  Database management system (DBMS)  Store large collections of data  Organize the data  Becomes a data storage system.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Visual Programing SQL Overview Section 1.
IMS 4212: Data Manipulation 1 Dr. Lawrence West, MIS Dept., University of Central Florida Additional Data Manipulation Statements INSERT.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
Object storage and object interoperability
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
Relational Databases and MySQL. Relational Databases Relational databases model data by storing rows and columns in tables. The power of the relational.
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata RDBMS Concepts.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
CDT/1 Creating data tables and Referential Integrity Objective –To learn about the data constraints supported by SQL2 –To be able to relate tables together.
LEC-8 SQL. Indexes The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading.
Lecture 1.21 SQL Introduction Steven Jones, Genome Sciences Centre.
DAY 20: ACCESS CHAPTERS 5, 6, 7 Larry Reaves October 28,
Creating Database Objects
SQL and SQL*Plus Interaction
ORACLE SQL Developer & SQLPLUS Statements
Creating Database Objects
Presentation transcript:

FOCUS to DB2 By: Meadow Heath

FOCUS to DB2 Define DB2 table to FOCUS How FOCUS processes a DB2 request FOCUS to DB2 Efficiencies

Define DB2 table to FOCUS CAR Master File Description CAR Access File Description

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 . . .

CAR ACCESS File SEGNAME= CAR ,TABLENAME= '”IBI".”CAR"' ,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

FOCUS to DB2 Processing High level diagram of process FOCUS Request DB2 Interface Results

FOCUS Request Programmer submits a FOCEXEC: TABLE FILE CAR PRINT CAR MODEL DEALER_COST RETAIL_COST END

High Level Diagram of Process DB2 Interface (creates SQL) FOCUS (Processing) db2 request focexec Programmer executes FOCEXEC FOCUS parses request and passes to DB2 Interface

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;

High Level Diagram of Process db2 results DB2 Interface (creates SQL) FOCUS (Processing) results db2 request focexec d a t s q l Programmer executes FOCEXEC FOCUS parses request and passes to DB2 Interface RDBMS DB2 Interface builds SQL & passes to RDBMS RDBMS retrieves data from DB2 table(s) RDBMS returns data to DB2 Interface Table Table FOCUS completes any process not handled by DB2 Results returned to programmer

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

FOCUS to DB2 Efficiencies Sorting Data Selection Criteria Data Calculations How to determine efficiency

Sorting Data Sorting Defined field Sorting on DB2 field

Sorting on Define field FOCEXEC: DEFINE FILE CAR NEW_NAME/A3 =EDIT(MODEL,'999'); END TABLE FILE CAR PRINT CAR BY NEW_NAME 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.

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 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.

Selection Criteria Selecting from fields created with User-written subroutines Selecting from fields created with Edit feature

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' 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.

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' 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.

Data Calculations Calculations in a Compute Calculations in a Define

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.

Calculations in Define FOCEXEC: DEFINE FILE CAR NEW_AMT/D7 =RETAIL_COST - DEALER_COST; END TABLE FILE CAR SUM NEW_AMT BY CAR 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.

How to determine efficiency Test efficiency with FSTRACE4 FSTRACE4 shows the translation into SQL code 1) DYNAM ALLOC FILE FSTRACE4 * (OR ALLOCATE TO A FILE) 2) Execute your FOCEXEC 3) Review FSTRACE4 to verify that the DB2 Translator converted your FOCEXEC into SQL code where possible

Summary Define DB2 table to FOCUS in the Master File Description and Access File Description

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".”CAR"' ,KEYS= 0 ,WRITE= YES ,$

Summary Define DB2 table to FOCUS in the Master File Description and Access File Description The DB2 Translator translates the FOCEXEC into SQL code to be passed to the RDBMS

High Level Diagram of Process db2 results DB2 Interface (creates SQL) FOCUS (Processing) results db2 request focexec d a t s q l Programmer executes FOCEXEC FOCUS parses request and passes to DB2 Interface RDBMS DB2 Interface builds SQL & passes to RDBMS RDBMS retrieves data from DB2 table(s) RDBMS returns data to DB2 Interface Table Table FOCUS completes any process not handled by DB2 Results returned to programmer

Summary Define DB2 table to FOCUS in the Master File Description and Access File Description The DB2 Translator translates the FOCEXEC into SQL code to be passed to the RDBMS Write your FOCEXEC to be more efficient by making DB2 do most of the work

DB2 should do most of the work DB2 Translator should be able to convert your data processing into SQL code when: Sorting Data Selection Criteria Data Calculations Test efficiency with FSTRACE4

Questions