Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

Pemrograman Basis Data

Overview of SQL PL Language Element


Tri Afirianto,
S.T., M.T.
tri.afirianto@ub
.ac.id

Unit Objectives
After completing this unit, you should be
able to:
Discuss DB2 data types
Select the proper data types
Work with user-defined data types
Work with Row data type
Work with Associative arrays
Implement data type anchoring

DB2 Built-in Data Types

User-Defined Distinct Types


UDTs User-Defined Data Types
Defined on existing data types
Generates a function to cast between the
distinct type and its source type
Generates a function to cast between the
source type and its distinct type

Used to enforce business rules

ROW Data Type

ARRAY Data Type


Conventional array
CREATE TYPE arrType AS INTEGER
ARRAY[1000];

Associative array
CREATE TYPE arrType2 AS INTEGER
ARRAY[VARCHAR(100)];
CREATE TYPE arrType3 AS myRowType
ARRAY[VARCHAR(100)];

Associative Arrays: Example

Associative Arrays: Example

Data Type Anchoring


Keep procedural variables in sync with
table columns
Scalar anchoring
DECLARE empSalary ANCHOR
employee.salary;

Row anchoring
DECLARE emp ANCHOR ROW employee;
BEGIN

DECLARE emp ANCHOR ROW employee;


SET emp.empno=000100;
SET emp.lastname=McClung;
SET emp.firstname=Naomi;

Unit Summary
Having completed this unit, you should be
able to:
Discuss DB2 data types
Select the proper data types
Work with user-defined data types
Work with Row data type
Work with Associative arrays
Implement data type anchoring

You might also like