SQL-PL Array Processing in DB2 Tony Andrews Twitter

Size: px
Start display at page:

Download "SQL-PL Array Processing in DB2 Tony Andrews Twitter"

Transcription

1 SQL-PL Array Processing in DB2 Tony Andrews Twitter

2 Questions? I will try my best to get to some questions towards the end of the webinar. You can submit questions by typing into the questions area of your webinar control panel. Any questions not answered due to time constraints can be answered afterward via an . 2

3 Webinar Objectives Understand the key areas that can cause performance issues with DB2 queries and applications Better understand DB2 optimization Understand how DB2 database design affects performance Understand DB2 data distribution statistics. How does it affect performance Understand SQL efficient coding 3

4 Webinar Objectives Objective 1: To learn the rules of coding and defining SQL- PL variable array data types. Objective 2: To learn about the many array functions (ARRRAY_AGG, ARRARY_DELETE, TRIM_ARRAY, UNNEST, CARDINALITY, and more). Objective 3: Learn uses of the Array Constructor. Objective 4: Learn the basic array operations like (Sub- Indexing, Cardinality, Trimming, etc) Objective 5: Learn how to turn a result set into an array, an array of elements into a table, etc.). Get empowered! New as of Db2 LUW 9.5, Db2 for I 7.1, and z/os V11. 4

5 What is an Array? An array is a user-defined data type that consists of an ordered set of elements of a single built-in data type. Array entries (elements) can be accessed and modified by their index position. Going beyond the max entry gets an SQLCODE= An array index with value xx is null, out of range or does not exist Must first create an array datatype and then use it to define a stored procedure parameter, SQL-PL declared variable, or global variable (V12).

6 Why Arrays? Processing, passing, holding lists of data can often times be bulky and inefficient. Replaces the use of tables (either permanent or GTT) Replaces the use of a string list variable, and then having to unstring/decode through the list. Replaces a long list of input/output parameters The fact that arrays are quite common in most programming languages. Test have shown a performance improvement over GTTs, Long Varchars, and returned results sets

7 SQL-PL Array Rules Arrays in SQL-PL are allocated and de-allocated dynamically. Memory allocation is based on the cardinality (# entries loaded into the array), and not on the possible maximum. All elements of array must have same data type An array can contain a set of values, can contain no values (as in null values), or the column with array data type can be null Individual elements can contain a value or be null The cardinality of the array is equal to the number of elements in the array, not the max number that it can hold

8 SQL-PL Array Rules Can Java handle SQL-PL Arrays? Yes via the IBM Data Server Driver for JDBC and SQLJ type 4 driver). Some code later. This was a big request from the JAVA development community. Can COBOL handle SQL-PL arrays? No. Two types of arrays: Ordinary: where items are addressed by their ordinal position within the array). Associative: where items are ordered by a defined array index value.

9 SQL-PL Array Definition Arrays are created using the CREATE TYPE command (UDT): CREATE TYPE name AS data_type ARRAY[size] Includes the name of the array, data_type ARRAY, and the number of occurrences. The number of occurrences can be fixed or open ended: CREATE TYPE DEPT_ARRAY AS CHAR(3) ARRAY[5] ; CREATE TYPE DEPT_ARRAY AS CHAR(3) ARRAY[] ;

10 SQL-PL Array Functions ARRAY: Adds data elements to an array ARRAY_AGG: Adds data elements to an by extracting data form a Db2 table TRIM_ARRAY: Removes data elements from an array DELETE_ARRAY: Deletes the array UNNEST: returns a result table from the data elements in an array CARDINALITY: Provides the number of data elements currently in an array MAX_CARDINALITY: Provides the maximum value specified in Create ARRAY_FIRST: Returns the minimum array index value in the array ARRAY_LAST: Returns the maximum array index value in the array ARRAY_NEXT: Next element relative to current

11 SQL-PL ARRAY Function - Example 1 Load an ordinary array from hard coded values. Based on: CREATE TYPE DEPT_LIST AS CHAR(3) ARRAY[] ; Define the type DECLARE V_DEPT_LIST DEPT_LIST; Use the type SET V_DEPT_LIST = ARRAY[ D01, D11, D21 ]; Note: Square brackets, not parenthesis SET V_CARDINALITY = CARDINALITY (V_DEPTNO_LIST); V_CARDINALITY would be 3.

12 SQL-PL ARRAY Function - Example 2 Load an ordinary array from variable fields SET V_DEPTNO_LIST = ARRAY [V_DEPTNO1, V_DEPTNO2, V_DEPTNO3 ];

13 SQL-PL ARRAY Function - Example 3 Use a SELECT with the ARRAY function SET V_DEPTNO_LIST = ARRAY[SELECT DEPTNO FROM EMP];

14 SQL-PL ARRAY Function - Example 4 Use a SELECT with the ARRAY SET V_DEPTNO_LIST = ARRAY[SELECT DEPTNO FROM EMP ORDER BY DEPTNO FETCH FIRST 3 ROWS ONLY];

15 SQL-PL ARRAY Function - Example 5 Can also use the word NULL, and a Scalar Fullselect SET V_DEPTNO_LIST = ARRAY [NULL, V_DEPTNO2, (SELECT DEPTNO FROM DEPT WHERE DEPTNO LIKE D% FETCH FIRST 1 ROW ONLY) ];

16 SQL-PL ARRAY_AGG Function - Example 1 Load up the DEPTNO array with values from the EMP table using a SET statement SET V_DEPTNO_LIST = (SELECT ARRAY_AGG(DEPTNO ORDER BY DEPTNO) FROM DEPT WHERE DEPTNO LIKE 'D%' FETCH FIRST 3 ROWS ONLY );

17 SQL-PL ARRAY_AGG Function - Example 2 Distinct cannot be used directly in the ARRAY_AGG Set select SET V_DEPTNO_LIST = (SELECT ARRAY_AGG(DEPTNO ORDER BY DEPTNO) FROM (SELECT DISTINCT DEPTNO FROM THEMIS90.PROJ WHERE DEPTNO LIKE 'D%' FETCH FIRST 3 ROWS ONLY ) );

18 SQL-PL ARRAY_AGG Function - Example 3 You can select directly into. But with some exceptions SELECT ARRAY_AGG(DEPTNO) INTO V_DEPTNO_LIST FROM DEPT WHERE DEPTNO LIKE 'D%'

19 SQL-PL ARRAY_AGG Function - Example 3 You cannot however do a fetch first. Deploy Error: SELECT ARRAY_AGG(DEPTNO) INTO V_DEPTNO_LIST FROM DEPT WHERE DEPTNO LIKE 'D%' FETCH FIRST 3 ROWS ONLY; stored procedure returns SQLCODE: -490, SQLSTATE: 428B7. NUMBER 3 DIRECTLY SPECIFIED IN AN SQL STATEMENT IS OUTSIDE THE RANGE OF ALLOWABLE VALUES IN Deploy failed.

20 SQL-PL ARRAY_AGG Function - Example 4 You cannot however do an order by. SELECT ARRAY_AGG(DEPTNO) INTO V_DEPTNO_LIST FROM DEPT WHERE DEPTNO LIKE 'D%' ORDER BY DEPTNO; Deploy Error: Create stored procedure returns SQLCODE: -390, SQLSTATE: THE OBJECT ARRAY_AGG, SPECIFIC NAME *N, IS NOT VALID IN THE CONTEXT WHERE IT IS USED. SQLCODE=-390, SQLSTATE=42887, Deploy failed.

21 SQL-PL ARRAY_AGG Function - Example 5 You can however code them in a table expression. SELECT ARRAY_AGG(DEPTNO) INTO V_DEPTNO_LIST FROM (SELECT DEPTNO FROM THEMIS90.DEPT WHERE DEPTNO LIKE 'D%' ORDER BY DEPTNO FETCH FIRST 3 ROWS ONLY) Deployed!!!!

22 SQL-PL Emptying an array To empty an array SET V_DEPTNO_LIST = NULL; Sets the variable to null SET V_CARDINALITY = CARDINALITY (V_DEPTNO_LIST); V_CARDINALITY is null not 0. SET V_DEPTNO_LIST = ARRAY[]; Empties the variable SET V_CARDINALITY = CARDINALITY (V_DEPTNO_LIST); V_CARDINALITY = 0.

23 SQL-PL CARDINALITY CARDINALITY SET DEPT_LIST [5] = F22 ; Sets the 5 th element in array CARDINALITY would be 5. SET V_DEPTNO = V_DEPT_LIST[6] Would get an error due to that occurrence not existing yet SQLCODE What if? SET V_DEPT_LIST [7] = G22 ; and then SET V_DEPTNO = V_DEPT_LIST[6] V_DEPT set to nulls!

24 SQL-PL UNNEST Example 1 The UNNEST treats the array like a table SELECT COUNT(*) INTO P_OUT_COUNT FROM EMP WHERE DEPTNO IN (SELECT IN.DEPT FROM UNNEST(P_DEPTNO_LIST) AS IN(DEPT) ) ;

25 SQL-PL UNNEST WITH ORDINALITY Example 2 CREATE TABLE DEPT_EMEA ( POSITION INT, DEPTNO CHAR(3) ) ; INSERT INTO DEPT_EMEA(DEPTNO, POSITION) SELECT * FROM UNNEST(V_DEPTNO_LIST) WITH ORDINALITY AS (DEPTNO, POSITION) ; SELECT * FROM DEPT_EMEA ; POSITION DEPTNO - 1 D01 2 D11 3 D21

26 SQL-PL UNNEST Example 3 SELECT P.PROJNO, P.PROJNAME FROM PROJ P, UNNEST(P_DEPTPNO_LIST) AS V(DEPTNO) WHERE P.DEPTNO = V.DEPTNO

27 SQL-PL Associative Arrays Arrays in SQL-PL that assign a unique key to a value No maximum cardinality is defined (open ended) Create statement needs to have index datatype specified Must be integer or varchar (or you get SQLCODE=-20436) The associative array index values do not have to be ordered Can be sparse Each element in the array can be referenced by an associated index value CREATE TYPE STATES_ARRAY AS VARCHAR(16) ARRAY[VARCHAR(02)];

28 SQL-PL Associative Arrays CREATE TYPE STATES_ARRAY AS VARCHAR(16) ARRAY[VARCHAR(02)]; The data type VARCHAR(16) after the AS keyword refers to the data values (in this case state names) stored in the array. Ex: Ohio, Alabama, etc.. The ARRAY[VARCHAR(02)] indicates that this is an associative array and will contain the index values. For this example OH, AL, etc.

29 SQL-PL Associative Arrays The order in which values are assigned to array elements in an associative array does not matter, but they will be re-ordered in the order of the index values: For example: DECLARE V_STATE_NAMES STATES_ARRAY; SET V_STATE_NAMES['OH'] = 'Ohio'; SET V_STATE_NAMES['AL'] = 'Alabama'; SET P_STATE_INDEX = ARRAY_FIRST(V_STATE_NAMES); P_STATE_INDEX will equal AL

30 SQL-PL Associative Arrays How do we get the state names out of the array after they are loaded? You need to have an index state code value, with hard coded or from a variable. For example: DECLARE V_STATE_NAMES STATES_ARRAY; SET V_STATE_NAMES['OH'] = 'Ohio'; SET V_STATE_NAMES['AL'] = 'Alabama'; SET P_STATE_NAME = V_STATE_NAMES['OH']; P_STATE_NAME will equal Ohio

31 SQL-PL Associative Arrays What if we try to set a variable or parameter with a value using and index value that does not exists in the table? For example: SET P_STATE_NAME = V_STATE_NAMES[ XX']; SQLCODE AN ARRAY INDEX WITH VALUE XX IS NULL, OUT OF RANGE OR DOES NOT EXIST SET P_STATE_NAME = V_STATE_NAMES[ oh']; Note lower case SQLCODE AN ARRAY INDEX WITH VALUE oh IS NULL, OUT OF RANGE OR DOES NOT EXIST

32 SQL-PL Arrays and Java Java programs must accesses the DB2 for z/os server via the IBM Data Server Driver for JDBC and SQLJ type 4 driver To pass an array to a stored procedure, use the createarrayof() method of the Connection object Creates a java.sql.array object of the specified type Use the underlying datatype of the array element Do not try to use the UDT name The first example that follows accepts an array as it's first parameter The example following that one returns an array as it's 2 nd parameter

33 SQL-PL V12 Enhancements z/os Db2 11 provided support for the array data type Db2 also allows for global variables, but not defined as an array Db2 12 provides for using an associative array as an argument to the ARRAY_AGG function

34 Thank you for allowing me and Themis to share some of our experience and knowledge today! Tony Andrews I hope that you learned something new today!!!!

35 The material in this presentation is further developed in the following Themis courses: DB1029 Exploiting SQL-PL Native Stored Procedures on z/os DB1028 DB2 LUW SQL-PL Stored Procedure Development DB1070 Advanced Query, Native Stored Procedures, and Query Tuning on DB2 for z/os Links to these courses may be found at: Tony s tandrews@themisinc.com

36 Education. Check out Finally! A book of DB2 SQL tuning tips for developers, specifically designed to improve performance. DB2 SQL developers now have a handy reference guide with tuning tips to improve performance in queries, programs and applications.

37 Education. Check Out On-site and Public Instructor -led Hands-on Customization Experience Over 30 DB2 courses Over 400 IT courses US Intl

Db2 User-Defined Functions

Db2 User-Defined Functions Db2 User-Defined Functions David Simpson Themis Education dsimpson@themisinc.com www.themisinc.com @ThemisDave @ThemisTraining Themis Education Most complete DB2 Curriculum in the industry Offerings include

More information

The SQL Procedure Language (SQL PL)

The SQL Procedure Language (SQL PL) The SQL Procedure Language (SQL PL) Tony Andrews Themis Education tandrews@themisinc.com www.themisinc.com Coding a SQL PL Procedure An SQL procedure consists of: CREATE PROCEDURE header BEGIN statement

More information

DB2 SQL for the 21 st Century: Overlooked Enhancements. David Simpson

DB2 SQL for the 21 st Century: Overlooked Enhancements. David Simpson DB2 SQL for the 21 st Century: Overlooked Enhancements David Simpson dsimpson@themisinc.com Themis Education Most complete DB2 Curriculum in the industry Offerings include a complete mainframe curriculum

More information

Advanced SQL and the Power of Rewriting Queries

Advanced SQL and the Power of Rewriting Queries Advanced SQL and the Power of Rewriting Queries Tony Andrews Themis Inc. Session Code: E07 Tuesday May24, 10:30 Platform: Application Developer Track Photo by Steve from Austin, TX, USA Often times there

More information

Chapter 13 Introduction to SQL Programming Techniques

Chapter 13 Introduction to SQL Programming Techniques Chapter 13 Introduction to SQL Programming Techniques Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Outline Database Programming: Techniques and Issues Embedded

More information

IBM C DB2 9.5 SQL Procedure Developer.

IBM C DB2 9.5 SQL Procedure Developer. IBM C2090-735 DB2 9.5 SQL Procedure Developer https://killexams.com/pass4sure/exam-detail/c2090-735 QUESTION: 88 Click the Exhibit button. The file myscript.sql (shown in the exhibit) is executed from

More information

Lesson 13 Transcript: User-Defined Functions

Lesson 13 Transcript: User-Defined Functions Lesson 13 Transcript: User-Defined Functions Slide 1: Cover Welcome to Lesson 13 of DB2 ON CAMPUS LECTURE SERIES. Today, we are going to talk about User-defined Functions. My name is Raul Chong, and I'm

More information

Application-enabling features of DB2 for z/os. June Charles Lewis DB2 for z/os Advisor IBM Mid-Atlantic Business Unit

Application-enabling features of DB2 for z/os. June Charles Lewis DB2 for z/os Advisor IBM Mid-Atlantic Business Unit Application-enabling features of DB2 for z/os June 2016 Charles Lewis DB2 for z/os Advisor IBM Mid-Atlantic Business Unit lewisc@us.ibm.com The aim of this presentation To help ensure that you are aware

More information

My Favorite Things in DB2 11 for z/os

My Favorite Things in DB2 11 for z/os My Favorite Things in DB2 11 for z/os Martin Hubel + 1 905-764-7498 martin@mhubel.com www.mhubel.com Copyright 2015 Martin Hubel Consulting Inc. 1 Frame of Reference I have worked with DB2 for z/os since

More information

DB2 for z/os, Enhanced System-Period Temporal Tables!

DB2 for z/os, Enhanced System-Period Temporal Tables! DB2 for z/os, Enhanced System-Period Temporal Tables! lclaussen@themisinc.com Slides Available For Download www.themisinc.com/webinars Questions? You can submit questions by typing into the questions area

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 10 Outline Database Programming: Techniques and Issues Embedded SQL, Dynamic SQL, and SQLJ Database Programming with Function Calls: SQL/CLI and JDBC Database Stored Procedures and SQL/PSM Comparing

More information

DB2 Advanced SQL Working with Complex Queries. Tony Andrews, Application Tuning Consultant Themis, Inc.

DB2 Advanced SQL Working with Complex Queries. Tony Andrews, Application Tuning Consultant Themis, Inc. DB2 Advanced SQL Working with Complex Queries Tony Andrews, Application Tuning Consultant Themis, Inc. tandrews@themisinc.com www.themisinc.com DB2 Advanced SQL Working with Complex Queries Themis and

More information

IBM Data Studio for Mainframe Developers. David Simpson, Senior Technical Advisor Themis, Inc.

IBM Data Studio for Mainframe Developers. David Simpson, Senior Technical Advisor Themis, Inc. IBM Data Studio for Mainframe Developers David Simpson, Senior Technical Advisor Themis, Inc. dsimpson@themisinc.com www.themisinc.com IBM Data Studio for Mainframe Developers Themis and Themis, Inc. are

More information

DB2 SQL Tuning Tips for z/os Developers

DB2 SQL Tuning Tips for z/os Developers DB2 SQL Tuning Tips for z/os Developers Tony Andrews IBM Press, Pearson pic Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Cape Town Sydney

More information

Optional SQL Feature Summary

Optional SQL Feature Summary Optional SQL Feature Summary The following table lists all optional features included in the SQL standard, from SQL- 2003 to SQL-2016. It also indicates which features that are currently supported by Mimer

More information

SQL Structured Query Language Introduction

SQL Structured Query Language Introduction SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also

More information

ITCS Implementation. Jing Yang 2010 Fall. Class 14: Introduction to SQL Programming Techniques (Ch13) Outline

ITCS Implementation. Jing Yang 2010 Fall. Class 14: Introduction to SQL Programming Techniques (Ch13) Outline ITCS 3160 Data Base Design and Implementation Jing Yang 2010 Fall Class 14: Introduction to SQL Programming Techniques (Ch13) Outline Database Programming: Techniques and Issues Three approaches: Embedded

More information

HOLDDATA FOR DB2 9.1 PUT Level ** Please read through all the holddata before acting on any of it. ** GENERAL

HOLDDATA FOR DB2 9.1 PUT Level ** Please read through all the holddata before acting on any of it. ** GENERAL HOLDDATA FOR DB2 9.1 PUT Level 0805 ** Please read through all the holddata before acting on any of it. ** GENERAL 1. Rebind all static DB2 application which match criteria. Member REBIND DSN910.SVSC.HOLDCNTL

More information

Sample Paper 2011 Class XII Subject Informatics Practices Time 03 hrs Max Marks 70 General Instructions:- 1. All questions are compulsory. 2. Question paper carries A, B & C Three parts. 3. Section A is

More information

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity COSC 416 NoSQL Databases Relational Model (Review) Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was proposed by E. F. Codd

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

Overview of DB2 11 and DB2 12 SQL Enhancements

Overview of DB2 11 and DB2 12 SQL Enhancements Overview of DB2 11 and DB2 12 SQL Enhancements Christopher J. Crone IBM Session Code: 3 Platform: DB2 for z/os Agenda Overview of the Family DB2 11 DB2 12 Summary Overview of the Family DB2 SQL z DB2 11

More information

Going Native: Leveraging DB2 for z/os Native SQL Procedures and User-Defined Functions

Going Native: Leveraging DB2 for z/os Native SQL Procedures and User-Defined Functions Robert Catterall, IBM rfcatter@us.ibm.com Going Native: Leveraging DB2 for z/os Native SQL Procedures and User-Defined Functions New England DB2 Users Group March 26, 2015 Information Management 2015 IBM

More information

Interpreting Explain Plan Output. John Mullins

Interpreting Explain Plan Output. John Mullins Interpreting Explain Plan Output John Mullins jmullins@themisinc.com www.themisinc.com www.themisinc.com/webinars Presenter John Mullins Themis Inc. (jmullins@themisinc.com) 30+ years of Oracle experience

More information

Oracle Create Table Foreign Key On Delete No

Oracle Create Table Foreign Key On Delete No Oracle Create Table Foreign Key On Delete No Action Can I create a foreign key against only part of a composite primary key? For example, if you delete a row from the ProductSubcategory table, it could

More information

DB2 9 for z/os Selected Query Performance Enhancements

DB2 9 for z/os Selected Query Performance Enhancements Session: C13 DB2 9 for z/os Selected Query Performance Enhancements James Guo IBM Silicon Valley Lab May 10, 2007 10:40 a.m. 11:40 a.m. Platform: DB2 for z/os 1 Table of Content Cross Query Block Optimization

More information

20 Essential Oracle SQL and PL/SQL Tuning Tips. John Mullins

20 Essential Oracle SQL and PL/SQL Tuning Tips. John Mullins 20 Essential Oracle SQL and PL/SQL Tuning Tips John Mullins jmullins@themisinc.com www.themisinc.com www.themisinc.com/webinars Presenter John Mullins Themis Inc. (jmullins@themisinc.com) 30+ years of

More information

An Introduction to SQL for System i. A beginning overview of SQL in System i Navigator and Embedded SQL in RPGLE

An Introduction to SQL for System i. A beginning overview of SQL in System i Navigator and Embedded SQL in RPGLE An Introduction to SQL for System i A beginning overview of SQL in System i Navigator and Embedded SQL in RPGLE Quote heard from IBM at a Conference 80% of everything you will need to know three years

More information

Slides by: Ms. Shree Jaswal

Slides by: Ms. Shree Jaswal Slides by: Ms. Shree Jaswal A trigger is a statement that is executed automatically by the system as a side effect of a modification to the database. To design a trigger mechanism, we must: Specify the

More information

DB2 for z/os Stored Procedures Update

DB2 for z/os Stored Procedures Update Robert Catterall, IBM rfcatter@us.ibm.com DB2 for z/os Stored Procedures Update Michigan DB2 Users Group May 15, 2013 Information Management Agenda A brief review of DB2 for z/os stored procedure enhancements

More information

SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8.

SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8. SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8.4 of Garcia-Molina Slides derived from those by Jeffrey D. Ullman SQL and Programming

More information

Chapter 4 Application Programs and Object-Relational Capabilities

Chapter 4 Application Programs and Object-Relational Capabilities Chapter 4 Application Programs and Object-Relational Capabilities Recent Development for Data Models 2016 Stefan Deßloch The "Big Picture" SQL99 Client DB Server Server-side Logic dynamic SQL JDBC 2.0

More information

Databases IIB: DBMS-Implementation Exercise Sheet 13

Databases IIB: DBMS-Implementation Exercise Sheet 13 Prof. Dr. Stefan Brass January 27, 2017 Institut für Informatik MLU Halle-Wittenberg Databases IIB: DBMS-Implementation Exercise Sheet 13 As requested by the students, the repetition questions a) will

More information

Native Stored Procedures Best Practices

Native Stored Procedures Best Practices Native Stored Procedures Best Practices Exploiting Native SQL Stored Procedures Native Stored Procedures Best Practices What is a Native Stored Procedure? They are simply packages, with "runtime structures"

More information

S.Q.L. in SQL. David Andruchuk Sr. Architect Computer Systems Design Associates, Inc. What can i do..i can do SQL

S.Q.L. in SQL. David Andruchuk Sr. Architect Computer Systems Design Associates, Inc. What can i do..i can do SQL S.Q.L. in SQL David Andruchuk Sr. Architect Computer Systems Design Associates, Inc. What can i do..i can do SQL What are we covering today? SQL Objects (Objects written in SQL and known to the DBMS) File

More information

IBM DB2 UDB V7.1 Family Fundamentals.

IBM DB2 UDB V7.1 Family Fundamentals. IBM 000-512 DB2 UDB V7.1 Family Fundamentals http://killexams.com/exam-detail/000-512 Answer: E QUESTION: 98 Given the following: A table containing a list of all seats on an airplane. A seat consists

More information

Overview of DB2 10 and DB2 11 SQL Enhancements. Christopher J. Crone IBM

Overview of DB2 10 and DB2 11 SQL Enhancements. Christopher J. Crone IBM Overview of DB2 10 and DB2 11 SQL Enhancements Christopher J. Crone IBM 2 Agenda Overview of DB2 Family SQL Functionality Review of DB2 10 SQL Enhancements Introduction to DB2 11 Enhancements Summary of

More information

COMP 430 Intro. to Database Systems

COMP 430 Intro. to Database Systems SELECT name FROM sqlite_master WHERE type='table' COMP 430 Intro. to Database Systems Single-table SQL Get clickers today! Slides use ideas from Chris Ré and Chris Jermaine. Clicker test Have you used

More information

Unit 1 - Chapter 4,5

Unit 1 - Chapter 4,5 Unit 1 - Chapter 4,5 CREATE DATABASE DatabaseName; SHOW DATABASES; USE DatabaseName; DROP DATABASE DatabaseName; CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype,... columnn

More information

Access Path Stability on Db2 for z/os. David Simpson

Access Path Stability on Db2 for z/os. David Simpson Access Path Stability on Db2 for z/os David Simpson dsimpson@themisinc.com Themis Education Most complete DB2 Curriculum in the industry Offerings include a complete mainframe curriculum in addition to

More information

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford Database Programming Week 9 *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford SQL in Real Programs We have seen only how SQL is used at the generic query interface

More information

Reducing MIPS Using InfoSphere Optim Query Workload Tuner TDZ-2755A. Lloyd Matthews, U.S. Senate

Reducing MIPS Using InfoSphere Optim Query Workload Tuner TDZ-2755A. Lloyd Matthews, U.S. Senate Reducing MIPS Using InfoSphere Optim Query Workload Tuner TDZ-2755A Lloyd Matthews, U.S. Senate 0 Disclaimer Copyright IBM Corporation 2010. All rights reserved. U.S. Government Users Restricted Rights

More information

Db2 Sql Pl Guide. Db2 Sql Pl Guide

Db2 Sql Pl Guide. Db2 Sql Pl Guide We have made it easy for you to find a PDF Ebooks without any digging. And by having access to our ebooks online or by storing it on your computer, you have convenient answers with db2 sql pl guide. To

More information

To understand the concept of candidate and primary keys and their application in table creation.

To understand the concept of candidate and primary keys and their application in table creation. CM0719: Database Modelling Seminar 5 (b): Candidate and Primary Keys Exercise Aims: To understand the concept of candidate and primary keys and their application in table creation. Outline of Activity:

More information

Programming the Database

Programming the Database Programming the Database Today s Lecture 1. Stored Procedures 2. Functions BBM471 Database Management Systems Dr. Fuat Akal akal@hacettepe.edu.tr 3. Cursors 4. Triggers 5. Dynamic SQL 2 Stored Procedures

More information

DB2 for z/os: Continuous Delivery of New Features (part 2) Chris Crone DE DB2 Development Presented by Mark Rader WSC: DB2 for z/os

DB2 for z/os: Continuous Delivery of New Features (part 2) Chris Crone DE DB2 Development Presented by Mark Rader WSC: DB2 for z/os DB2 for z/os: Continuous Delivery of New Features (part 2) Chris Crone DE DB2 Development Presented by Mark Rader WSC: DB2 for z/os Applications Static SQL, DDL, and DCL In DB2 11, Static SQL is controlled

More information

Administration. Objects and Arrays. Objects. Agenda. What is an Object? What is a Class?

Administration. Objects and Arrays. Objects. Agenda. What is an Object? What is a Class? Administration Objects and Arrays CS 99 Summer 2000 Michael Clarkson Lecture 6 Read clarified grading policies Lab 6 due tomorrow Submit.java files in a folder named Lab6 Lab 7 Posted today Upson Lab closed

More information

First lecture of this chapter is in slides (PPT file)

First lecture of this chapter is in slides (PPT file) First lecture of this chapter is in slides (PPT file) Review of referential integrity CREATE TABLE other_table ( b1 INTEGER, c1 INTEGER, PRIMARY KEY (b1, c1) ) CREATE TABLE t ( a integer PRIMARY KEY, b2

More information

Advanced Constraints SQL. by Joe Celko copyright 2007

Advanced Constraints SQL. by Joe Celko copyright 2007 Advanced Constraints SQL by Joe Celko copyright 2007 Abstract The talk is a short overview of the options a programmer to use DDL (Data Declaration Language) in SQL to enforce a wide range of business

More information

IBM DB2 9 Application Developer. Practice Test. Version 1.1.

IBM DB2 9 Application Developer. Practice Test. Version 1.1. IBM 000-733 000-733 DB2 9 Application Developer Practice Test Version 1.1 QUESTION NO: 1 IBM 000-733: Practice Exam A.NET application executes a SQL request invoking the DB2Command.ExecuteReader method

More information

What do you mean the Oracle Optimizer won't use my Index? John Mullins

What do you mean the Oracle Optimizer won't use my Index? John Mullins What do you mean the Oracle Optimizer won't use my Index? John Mullins jmullins@themisinc.com www.themisinc.com www.themisinc.com/webinars Presenter John Mullins Themis Inc. (jmullins@themisinc.com) 32+

More information

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management 12 Advanced Topics Objectives Use indexes to improve database performance Examine the security features of a DBMS Discuss entity, referential, and legal-values integrity Make changes to the structure of

More information

CS143: Relational Model

CS143: Relational Model CS143: Relational Model Book Chapters (4th) Chapters 1.3-5, 3.1, 4.11 (5th) Chapters 1.3-7, 2.1, 3.1-2, 4.1 (6th) Chapters 1.3-6, 2.105, 3.1-2, 4.5 Things to Learn Data model Relational model Database

More information

Session: E08 Quit Calling DB2 So Much! Susan Lawson and Dan Luksetich YL&A. 14 October :40-17:40 Platform: z/os

Session: E08 Quit Calling DB2 So Much! Susan Lawson and Dan Luksetich YL&A. 14 October :40-17:40 Platform: z/os Session: E08 Quit Calling DB2 So Much! Susan Lawson and Dan Luksetich YL&A 14 October 2008 16:40-17:40 Platform: z/os 1 DB2 UDB for z/os 9/15/2008 Disclaimer PLEASE READ THE FOLLOWING NOTICE The information

More information

Get Table Schema In Sql Server 2008 Modify. Column Null >>>CLICK HERE<<<

Get Table Schema In Sql Server 2008 Modify. Column Null >>>CLICK HERE<<< Get Table Schema In Sql Server 2008 Modify Column Null SQL Server - Changing a column from NOT NULL to NULL - What's going on under the hood? No problem. SQL Server 2008 R2 INDEX if all the columns part

More information

Lesson 17 Transcript: Troubleshooting

Lesson 17 Transcript: Troubleshooting Lesson 17 Transcript: Troubleshooting Slide 1 - Cover Welcome to Lesson 17 of the DB2 on Campus lecture series. Today we're going to talk about troubleshooting. My name is Raul Chong, and I'm the DB2 on

More information

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] 1. What is DBMS? A Database Management System (DBMS) is a program that controls creation, maintenance and use

More information

The NoPlsql and Thick Database Paradigms

The NoPlsql and Thick Database Paradigms The NoPlsql and Thick Database Paradigms Part 2: Adopting ThickDB Toon Koppelaars Real-World Performance Oracle Server Technologies Bryn Llewellyn Distinguished Product Manager Oracle Server Technologies

More information

Database Application Development

Database Application Development Database Application Development Linda Wu (CMPT 354 2004-2) Topics SQL in application code Embedded SQL JDBC SQLJ Stored procedures Chapter 6 CMPT 354 2004-2 2 SQL in Application Code SQL commands can

More information

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies Databases - 4 Other relational operations and DDL How to write RA expressions for dummies Step 1: Identify the relations required and CP them together Step 2: Add required selections to make the CP Step

More information

C Q&As. DB2 9.7 SQL Procedure Developer. Pass IBM C Exam with 100% Guarantee

C Q&As. DB2 9.7 SQL Procedure Developer. Pass IBM C Exam with 100% Guarantee C2090-545 Q&As DB2 9.7 SQL Procedure Developer Pass IBM C2090-545 Exam with 100% Guarantee Free Download Real Questions & Answers PDF and VCE file from: https://www.pass4lead.com/c2090-545.html 100% Passing

More information

Principles of Data Management

Principles of Data Management Principles of Data Management Alvin Lin August 2018 - December 2018 Structured Query Language Structured Query Language (SQL) was created at IBM in the 80s: SQL-86 (first standard) SQL-89 SQL-92 (what

More information

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version :

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version : IBM A2090-730 Assessment: DB2 9 Fundamentals-Assessment Download Full Version : http://killexams.com/pass4sure/exam-detail/a2090-730 C. 2 D. 3 Answer: C QUESTION: 294 In which of the following situations

More information

V cover. Front cover. DB2 Stored Procedures Programming Workshop. (Course Code CF71) Student Exercises ERC 4.0. IBM Certified Course Material

V cover. Front cover. DB2 Stored Procedures Programming Workshop. (Course Code CF71) Student Exercises ERC 4.0. IBM Certified Course Material V2.0.0.1 cover Front cover DB2 Stored Procedures Programming Workshop (Course Code CF71) Student Exercises ERC 4.0 IBM Certified Course Material Student Exercises Trademarks IBM is a registered trademark

More information

Modern SQL: Evolution of a dinosaur

Modern SQL: Evolution of a dinosaur Modern SQL: Evolution of a dinosaur Markus Winand Kraków, 9-11 May 2018 Still using Windows 3.1? So why stick with SQL-92? @ModernSQL - https://modern-sql.com/ @MarkusWinand SQL:1999 WITH (Common Table

More information

Arrays are a very commonly used programming language construct, but have limited support within relational databases. Although an XML document or

Arrays are a very commonly used programming language construct, but have limited support within relational databases. Although an XML document or Performance problems come in many flavors, with many different causes and many different solutions. I've run into a number of these that I have not seen written about or presented elsewhere and I want

More information

1B1a Arrays. Arrays. Indexing. Naming arrays. Why? Using indexing. 1B1a Lecture Slides. Copyright 2003, Graham Roberts 1

1B1a Arrays. Arrays. Indexing. Naming arrays. Why? Using indexing. 1B1a Lecture Slides. Copyright 2003, Graham Roberts 1 Ba Arrays Arrays A normal variable holds value: An array variable holds a collection of values: 4 Naming arrays An array has a single name, so the elements are numbered or indexed. 0 3 4 5 Numbering starts

More information

Table of Contents Chapter 1 - Introduction Chapter 2 - Designing XML Data and Applications Chapter 3 - Designing and Managing XML Storage Objects

Table of Contents Chapter 1 - Introduction Chapter 2 - Designing XML Data and Applications Chapter 3 - Designing and Managing XML Storage Objects Table of Contents Chapter 1 - Introduction 1.1 Anatomy of an XML Document 1.2 Differences Between XML and Relational Data 1.3 Overview of DB2 purexml 1.4 Benefits of DB2 purexml over Alternative Storage

More information

Introduction to Functions and Variables

Introduction to Functions and Variables Introduction to Functions and Variables Functions are a way to add additional elements into your OBI Report. They enable you to manipulate data, perform computations and comparisons, and get system information.

More information

Chapter 1 SQL and Data

Chapter 1 SQL and Data Chapter 1 SQL and Data What is SQL? Structured Query Language An industry-standard language used to access & manipulate data stored in a relational database E. F. Codd, 1970 s IBM 2 What is Oracle? A relational

More information

OpenEdge Change Data Capture and the ETL Process WHITEPAPER AUTHOR : LAKSHMI PADMAJA

OpenEdge Change Data Capture and the ETL Process WHITEPAPER AUTHOR : LAKSHMI PADMAJA OpenEdge Change Data Capture and the ETL Process WHITEPAPER AUTHOR : LAKSHMI PADMAJA Introduction Keeping the multitude of data sources housed within an organization updated is a cumbersome and time intensive

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2017 CS 348 (Intro to DB Mgmt) SQL

More information

A First Book of ANSI C Fourth Edition. Chapter 8 Arrays

A First Book of ANSI C Fourth Edition. Chapter 8 Arrays A First Book of ANSI C Fourth Edition Chapter 8 Arrays Objectives One-Dimensional Arrays Array Initialization Arrays as Function Arguments Case Study: Computing Averages and Standard Deviations Two-Dimensional

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2016 CS 348 (Intro to DB Mgmt) SQL

More information

Advanced Query Tuning with IBM Data Studio. Tony Andrews Themis

Advanced Query Tuning with IBM Data Studio. Tony Andrews Themis Advanced Query Tuning with IBM Data Studio Tony Andrews Themis Session code:????????? Thu, May 03, 2018 (09:20 AM - 10:20 AM) Platform: Both Db2 LUW and z/os 1 1 Objectives By the end of this presentation,

More information

COMP 3400 Mainframe Administration 1

COMP 3400 Mainframe Administration 1 COMP 3400 Mainframe Administration 1 Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 These slides are based in part on materials provided by IBM s Academic Initiative. 1 Databases

More information

High-Level Database Models (ii)

High-Level Database Models (ii) ICS 321 Spring 2011 High-Level Database Models (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1 Logical DB Design: ER to Relational Entity sets to

More information

! An organized collection of data. ! Can easily be accessed, managed, and updated. ! Data are organized as a set of tables.

! An organized collection of data. ! Can easily be accessed, managed, and updated. ! Data are organized as a set of tables. What s Database INTRODUCTION OF DATABASE XIAOBO SUN! An organized collection of data! Can easily be accessed, managed, and updated Relational Database:! Data are organized as a set of tables.! Each table

More information

Themis and Themis, Inc. are trademarks of Themis, Inc.

Themis and Themis, Inc. are trademarks of Themis, Inc. Themis and Themis, Inc. are trademarks of Themis, Inc. DB2, IBM Data Studio, Visual Explain, Stored Procedure Builder, Rational and Control Center are trademarks of the IBM Corporation. Eclipse is a trademark

More information

Downloaded from

Downloaded from Lesson 16: Table and Integrity Constraints Integrity Constraints are the rules that a database must follow at all times. Various Integrity constraints are as follows:- 1. Not Null: It ensures that we cannot

More information

Db2 Sql Alter Table Add Column Default Value

Db2 Sql Alter Table Add Column Default Value Db2 Sql Alter Table Add Column Default Value The RazorSQL alter table tool includes an Add Column option for adding were can I modify de NULL & DEFAULT default values for DB2 V9.1 for z/os 1.11. Adds or

More information

Data Manipulation (DML) and Data Definition (DDL)

Data Manipulation (DML) and Data Definition (DDL) Data Manipulation (DML) and Data Definition (DDL) 114 SQL-DML Inserting Tuples INSERT INTO REGION VALUES (6,'Antarctica','') INSERT INTO NATION (N_NATIONKEY, N_NAME, N_REGIONKEY) SELECT NATIONKEY, NAME,

More information

Chapter 3 User-defined Routines and Object Behavior

Chapter 3 User-defined Routines and Object Behavior Chapter 3 User-defined Routines and Object Behavior Prof. Dr.-Ing. Stefan Deßloch Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de 1 Inhalt Überblick I. Objektorientierung und Erweiterbarkeit

More information

C Exam Questions Demo IBM. Exam Questions C

C Exam Questions Demo   IBM. Exam Questions C IBM Exam Questions C2090-543 DB2 9.7 Application Development (C2090-543) Version:Demo 1. Which condition will prevent a developer from using the DB2 Call Level Interface in an application? A. The developer

More information

Lecture 5: Arrays. A way to organize data. MIT AITI April 9th, 2005

Lecture 5: Arrays. A way to organize data. MIT AITI April 9th, 2005 Lecture 5: Arrays A way to organize data MIT AITI April 9th, 2005 1 What are Arrays? An array is a series of compartments to store data. Essentially a block of variables. In Java, arrays can only hold

More information

DB2 Stored Procedure and UDF Support in Rational Application Developer V6.01

DB2 Stored Procedure and UDF Support in Rational Application Developer V6.01 Session F08 DB2 Stored Procedure and UDF Support in Rational Application Developer V6.01 Marichu Scanlon marichu@us.ibm.com Wed, May 10, 2006 08:30 a.m. 09:40 a.m. Platform: Cross Platform Audience: -DBAs

More information

Chapter 2. DB2 concepts

Chapter 2. DB2 concepts 4960ch02qxd 10/6/2000 7:20 AM Page 37 DB2 concepts Chapter 2 Structured query language 38 DB2 data structures 40 Enforcing business rules 49 DB2 system structures 52 Application processes and transactions

More information

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of The SQL Query Language Data Definition Basic Query

More information

Introduction to Oracle Objects

Introduction to Oracle Objects This lab describes the advantages and key features of the Oracle object-relational model. The lab contains these topics: About Oracle Objects Advantages of Objects About Oracle Objects Oracle object types

More information

Tables From Existing Tables

Tables From Existing Tables Creating Tables From Existing Tables After completing this module, you will be able to: Create a clone of an existing table. Create a new table from many tables using a SQL SELECT. Define your own table

More information

DB2(R) SQL Procedure Language For Linux, UNIX And Windows (IBM DB2 Certification Guide Series) By Paul Yip;Drew Bradstock;Hana Curtis

DB2(R) SQL Procedure Language For Linux, UNIX And Windows (IBM DB2 Certification Guide Series) By Paul Yip;Drew Bradstock;Hana Curtis DB2(R) SQL Procedure Language For Linux, UNIX And Windows (IBM DB2 Certification Guide Series) By Paul Yip;Drew Bradstock;Hana Curtis If you are searched for the ebook by Paul Yip;Drew Bradstock;Hana Curtis

More information

Introduction to Data Management. Lecture #5 (E-R Relational, Cont.)

Introduction to Data Management. Lecture #5 (E-R Relational, Cont.) Introduction to Data Management Lecture #5 (E-R Relational, Cont.) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v HW#1 is due

More information

Database Programming with PL/SQL

Database Programming with PL/SQL Database Programming with PL/SQL 2-3 Objectives This lesson covers the following objectives: Define data type and explain why it is needed List and describe categories of data types Give examples of scalar

More information

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210 SQL: Concepts Todd Bacastow IST 210: Organization of Data 2/17/2004 1 Design questions How many entities are there? What are the major entities? What are the attributes of each entity? Is there a unique

More information

Lab Assignment 2. CIS 612 Dr. Sunnie S. Chung. Creating a User Defined Type (UDT) and Create a Table Function Using the UDT Data Type

Lab Assignment 2. CIS 612 Dr. Sunnie S. Chung. Creating a User Defined Type (UDT) and Create a Table Function Using the UDT Data Type CIS 612 Dr. Sunnie S. Chung Lab Assignment 2 Creating a User Defined Type (UDT) and Create a Table Function Using the UDT Data Type In a modern web application such as in a Data Analytic/Big data processing

More information

This lecture. PHP tags

This lecture. PHP tags This lecture Databases I This covers the (absolute) basics of and how to connect to a database using MDB2. (GF Royle 2006-8, N Spadaccini 2008) I 1 / 24 (GF Royle 2006-8, N Spadaccini 2008) I 2 / 24 What

More information

Creating SQL Tables and using Data Types

Creating SQL Tables and using Data Types Creating SQL Tables and using Data Types Aims: To learn how to create tables in Oracle SQL, and how to use Oracle SQL data types in the creation of these tables. Outline of Session: Given a simple database

More information

RDBMS Using Oracle. BIT-4 Lecture Week 3. Lecture Overview

RDBMS Using Oracle. BIT-4 Lecture Week 3. Lecture Overview RDBMS Using Oracle BIT-4 Lecture Week 3 Lecture Overview Creating Tables, Valid and Invalid table names Copying data between tables Character and Varchar2 DataType Size Define Variables in SQL NVL and

More information

Top 5 Issues that Cannot be Resolved by DBAs (other than missed bind variables)

Top 5 Issues that Cannot be Resolved by DBAs (other than missed bind variables) Top 5 Issues that Cannot be Resolved by DBAs (other than missed bind variables) March 12, 2013 Michael Rosenblum Dulcian, Inc. www.dulcian.com 1 of 43 Who Am I? Misha Oracle ACE Co-author of 2 books PL/SQL

More information

SQL. Char (30) can store ram, ramji007 or 80- b

SQL. Char (30) can store ram, ramji007 or 80- b SQL In Relational database Model all the information is stored on Tables, these tables are divided into rows and columns. A collection on related tables are called DATABASE. A named table in a database

More information