untitled

Similar documents
ストラドプロシージャの呼び出し方

~~~~~~~~~~~~~~~~~~ wait Call CPU time 1, latch: library cache 7, latch: library cache lock 4, job scheduler co

橡実践Oracle Objects for OLE

橡j_Oracle_whitepaper.PDF

Microsoft PowerPoint - 第5章補足-DB2組み込みSQL.ppt

1 SQL Server SQL Oracle SQL SQL* Plus PL/SQL 2 SQL Server SQL Server SQL Oracle SQL SQL*Plus SQL Server GUI 1-1 osql 1-1 Transact- SQL SELECTFROM 058

Microsoft Word - Lab5d-DB2組み込みSQL.doc

1 ex01.sql ex01.sql ; user_id from (select user_id ;) user_id * select select (3+4)*7, SIN(PI()/2) ; (1) select < > from < > ; :, * user_id user_name

3 Powered by mod_perl, Apache & MySQL use Item; my $item = Item->new( id => 1, name => ' ', price => 1200,

1,.,,,., RDBM, SQL. OSS,, SQL,,.

PowerPoint -O80_REP.PDF

Oracle Rdb: SQL Update

DB12.1 Beta HandsOn Seminar

,, create table drop table alter table

// JDBC // CallableStatement cs = null; try { cs = conn.preparecall("{call DUMMY_PROC(?,?)}"); cs.setstring(1, "This is a test"); cs.registeroutparame

(Microsoft Word - IBM i \203C\203\223\203^\201[\203l\203b\203g\203Z\203~\203i\201[_XMLTABLE.doc)

ODBC を使って MS SQL の ISE 2.1 を設定する

PowerRDBconnector説明書(SQLServer編)

KWCR3.0 instration

PBASIC 2.5 PBASIC 2.5 $PBASIC directive PIN type New DEBUG control characters DEBUGIN Line continuation for comma-delimited lists IF THEN ELSE * SELEC

Oracle Lite Tutorial

TM-m30 詳細取扱説明書

V-SFTのインストール及び画面データの転送手順 V-SFT Installation and Screen Data Transfer Procedure

[Lab 2]Oracleからの移行を促進する新機能

Advantage CA-Easytrieve Plus

XML Consortium & XML Consortium 1 XML Consortium XML Consortium 2

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for


Oracle Lite Tutorial

ストアドプロシージャ移行調査編

日本オラクル株式会社

…l…b…g…‘†[…N…v…“…O…›…~…fi…OfiÁŸ_

FileMaker ODBC and JDBC Guide

IBM Software Group DB2 Information Management Software DB2 V8 XML SQL/XML 2 XML XML UDF XMLExtender XML XML XMLCollection, XMLColumn XML UDF Informati

TM-T88VI 詳細取扱説明書

Microsoft Word - Win-Outlook.docx

橡ExCtrlPDF.PDF


untitled

Gray [6] cross tabulation CUBE, ROLL UP Johnson [7] pivoting SQL 3. SuperSQL SuperSQL SuperSQL SQL [1] [2] SQL SELECT GENERATE <media> <TFE> GENER- AT

FileMaker 16 ODBC と JDBC ガイド

Actual ESS Adapterの使用について

ハイウォーターマークを知る

PowerPoint Presentation

1.SqlCtl クラスリファレンス SqlCtl クラスのリファレンスを以下に示します メソッドの実行中にエラーが発生した場合は標準エラー出力にメッセージを出力します (1)Connect() メソッド データベースへ connect 要求を行います boolean Connect(String

TM-m30 詳細取扱説明書

K227 Java 2

n n n ( ) n Oracle 16 PostgreSQL 3 MySQL

2

Microsoft Word - 430_15_Developing_Stored_Procedure.doc

※サンプルアプリケーションを固めたファイル(orcasample

Microsoft Word - Meta70_Preferences.doc

untitled

WEB DB PRESS Vol.1 65

HA8000シリーズ ユーザーズガイド ~BIOS編~ HA8000/RS110/TS10 2013年6月~モデル

Oracle Rdb: PowerPoint Presentation

CAC

HA8000-bdシリーズ RAID設定ガイド HA8000-bd/BD10X2

MOTIF XF 取扱説明書

ii II Web Web HTML CSS PHP MySQL Web Web CSS JavaScript Web SQL Web

コンピュータ概論

セットアップカード

Introduction Purpose This training course describes the configuration and session features of the High-performance Embedded Workshop (HEW), a key tool

第10回 コーディングと統合(WWW用).PDF

test

Oracle Database 11g × Hitachi Storage Solutionsのベストプラクティス

JavaScript の使い方


Wiki Wiki Wiki...


MySQL5.0データベース ログファイルおよびステータスの収集

Compatibility list: vTESTstudio/CANoe

,,,,., C Java,,.,,.,., ,,.,, i

1 138

Transcription:

cibm() Information Management DB2 UDB V8.2 SQL cibm() Information Management 2

DB2 UDB V8.2 SQL cibm() Information Management 3 DB2 UDB V8.2 SQL cibm() Information Management 4

cibm() Information Management DB2 UDB V8.2 SQL cibm() Information Management 6

DB2 UDB V8.2 SQL cibm() Information Management 7 DB2 UDB V8.2 SQL cibm() Information Management 8

DB2 UDB V8.2 SQL CALL PROC(a_in,b_out); SELECT foo_scalar(c1) FROM T; SELECT a FROM T, TABLE(foo_table(T.c1)) F; SELECT C..foo_method() FROM T; cibm() Information Management 9 DB2 UDB V8.2 SQL F u n c t i o n a l i t y I m p l e m e n t a t i o n cibm() Information Management 10

DB2 UDB V8.2 SQL F u n c t i o n a l i t y I m p l e m e n t a t i o n cibm() Information Management 11 DB2 UDB V8.2 SQL cibm() Information Management 12

DB2 UDB V8.2 SQL cibm() Information Management 13 DB2 UDB V8.2 SQL cibm() Information Management 14

DB2 UDB V8.2 SQL cibm() Information Management 15 DB2 UDB V8.2 SQL Server Server DB2 DBM DB2 DBM Stored Procedure Client Client DB2 Client Application DB2 Client Application Network NetworkLogic cibm() Information Management 16

DB2 UDB V8.2 SQL cibm() Information Management 17 DB2 UDB V8.2 SQL CREATE PROCEDURE savepttest () LANGUAGE SQL BEGIN DECLARE COL1,COL2 SMALLINT ; DECLARE atend SMALLINT DEFAULT 0; DECLARE CUR1 CURSOR WITH HOLD FOR SELECT ROW_NUMBER,TEST_DATA FROM TEST_SOURCE ORDER BY ROW_NUMBER; DECLARE CONTINUE HANDLER FOR NOT FOUND SET atend=1; DECLARE EXIT HANDLER FOR SQLEXCEPTION SET atend=1; OPEN CUR1; FETCH CUR1 INTO COL1,COL2; nextrow: IF atend = 0 THEN SAVEPOINT svpt ON ROLLBACK RETAIN CURSORS; WHILE ( atend = 0 ) DO SET COL2 = COL2 + 100 ; UPDATE TEST_SOURCE SET TEST_DATA = COL2 WHERE row_number = COL1; FETCH CUR1 INTO COL1,COL2; END WHILE; IF COL2 > 400 THEN COMMIT; ELSE ROLLBACK TO SAVEPOINT svpt; RELEASE SAVEPOINT svpt; END IF; GOTO nextrow; END IF; END DB20000I The SQL command completed successfully. cibm() Information Management 18

DB2 UDB V8.2 SQL cibm() Information Management 19 DB2 UDB V8.2 SQL cibm() Information Management 20

DB2 UDB V8.2 SQL CREATE PROCEDURE psmuno() LANGUAGE SQL label: BEGIN DECLARE cur1 CURSOR WITH RETURN FOR SELECT * FROM employee END label Input (1) (2) SQL Parsing & generation SQL Precompilation.SQC source with SQL and #line statements C source C precompile listing with messages (3) C Compile and Link DB2 UDB catalog SYSCAT.PROCEDURES, SYSCAT.PROCPARMS Package dll installed in ~/sqllib//function/routine... cibm() Information Management 21 DB2 UDB V8.2 SQL CREATE PROCEDURE P() LANGUAGE SQL BEGIN DECLARE a INTEGER DEFAULT 10; WHILE a > 0 DO IF a / 2 = 0 THEN INSERT INTO T1 VALUES (a); ELSE INSERT INTO T2 VALUES (a); END IF; SET a = a -1; END WHILE; INSERT INTO T1 VALUES (a * 2); END SQL parsing & pre-compilation YES!. Byte Code Array Representing Procedural Control Flow + To drive execution of sections in the package File System Package DB2 Catalogs cibm() Information Management 22

DB2 UDB V8.2 SQL CREATE PROCEDURE P() LANGUAGE SQL BEGIN DECLARE a INTEGER DEFAULT 10; WHILE a > 0 DO IF a / 2 = 0 THEN INSERT INTO T1 VALUES (a); ELSE INSERT INTO T2 VALUES (a); END IF; SET a = a -1; END WHILE; INSERT INTO T1 VALUES (a * 2); END Bytecode Package with sections for these queries (SYSIBM.SYSCODEPROPERTIES.SQL_COMPILED_CODE) Begin: EvalQuery 0 While: EvalQuery 1 IfFalseGoto End EvalQuery 2 IfFalseGoto Else EvalQuery 3 Goto Endif Else: EvalQuery 4 Endif: EvalQuery 5 Goto While End: EvalQuery 6 VALUES (10) INTO :a; /* Query 0 */ VALUES (CASE WHEN :a > 0 THEN 1 ELSE 0) INTO :boolresult; /* Query 1 */ VALUES (CASE WHEN :a / 2 = 0 THEN 1 ELSE 0) INTO :boolresult; /* Query 2 */ INSERT INTO T1 VALUES (:a); /* Query 3 */ INSERT INTO T2 VALUES (:a); /* Query 4 */ VALUES (:a - 1) INTO :a; /* Query 5 */ INSERT INTO T1 VALUES (:a * 2); File System cibm() Information Management 23 DB2 UDB V8.2 SQL cibm() Information Management 24

DB2 UDB V8.2 SQL cibm() Information Management 25 DB2 UDB V8.2 SQL cibm() Information Management 26

DB2 UDB V8.2 SQL ==> db2 +c "insert into test_source values (101,101,'In-Flight')" DB20000I The SQL command completed successfully. cibm() Information Management 27 DB2 UDB V8.2 SQL P SP Specific cibm() Information Management 28

DB2 UDB V8.2 SQL cibm() Information Management 29 DB2 UDB V8.2 SQL ==> db2 connect to v8db cibm() Information Management 30

DB2 UDB V8.2 SQL OSV8.2 cibm() Information Management 31 DB2 UDB V8.2 SQL cibm() Information Management 32

DB2 UDB V8.2 SQL cibm() Information Management 33 DB2 UDB V8.2 SQL cibm() Information Management 34

cibm() Information Management DB2 UDB V8.2 SQL cibm() Information Management 36

DB2 UDB V8.2 SQL cibm() Information Management 37 DB2 UDB V8.2 SQL cibm() Information Management 38

DB2 UDB V8.2 SQL cibm() Information Management 39 DB2 UDB V8.2 SQL cibm() Information Management 40

DB2 UDB V8.2 SQL cibm() Information Management 41 DB2 UDB V8.2 SQL cibm() Information Management 42

DB2 UDB V8.2 SQL cibm() Information Management 43 DB2 UDB V8.2 SQL db2 '? SQL0270N' SQL0270N ( = "<reason-code>") : 70 71 SQL SQL CALL cibm() Information Management 44

DB2 UDB V8.2 SQL db2 '? SQL0751N' SQL0751N "<routine-name>" ( "<specific-name>") : COMMIT ROLLBACK (SAVEPOINT ) COMMIT ROLLBACK cibm() Information Management 45 DB2 UDB V8.2 SQL cibm() Information Management 46

DB2 UDB V8.2 SQL cibm() Information Management 47 DB2 UDB V8.2 SQL db2 '? SQL0746N' SQL0746N "<routine-name> ( "<specific-name>") "<table-name>" "<operation>" SQL : <routine-name> ( <specific-name> ) "<table-name>" "<operation>" cibm() Information Management 48

cibm() Information Management DB2 UDB V8.2 SQL cibm() Information Management 50

DB2 UDB V8.2 SQL cibm() Information Management 51 DB2 UDB V8.2 SQL cibm() Information Management 52

DB2 UDB V8.2 SQL cibm() Information Management 53 DB2 UDB V8.2 SQL cibm() Information Management 54

DB2 UDB V8.2 SQL cibm() Information Management 55 DB2 UDB V8.2 SQL cibm() Information Management 56

DB2 UDB V8.2 SQL (V8.1) (V8.2) cibm() Information Management 57 DB2 UDB V8.2 SQL (V8.1) (V8.2) cibm() Information Management 58

DB2 UDB V8.2 SQL V8.1 SQL20112N SAVEPOINTSAVEPOINT SAVEPOINTSQLSTATE=3B002 V8.2 SAVEPOINT cibm() Information Management 59 DB2 UDB V8.2 SQL cibm() Information Management 60

DB2 UDB V8.2 SQL cibm() Information Management 61 DB2 UDB V8.2 SQL SAVEPOINT cibm() Information Management 62

DB2 UDB V8.2 SQL SAVEPOINT cibm() Information Management 63 DB2 UDB V8.2 SQL SQL0910N SQL sqlcode : -910 sqlstate : 57007 cibm() Information Management 64

DB2 UDB V8.2 SQL cibm() Information Management 65 DB2 UDB V8.2 SQL cibm() Information Management 66

DB2 UDB V8.2 SQL cibm() Information Management 67 DB2 UDB V8.2 SQL cibm() Information Management 68

DB2 UDB V8.2 SQL T1DDL T3DDL C2 C1C3SQL0910N cibm() Information Management 69 DB2 UDB V8.2 SQL UOWRollback cibm() Information Management 70

DB2 UDB V8.2 SQL cibm() Information Management 71 DB2 UDB V8.2 SQL SAVEPOINT SAVEPOINTdrop cibm() Information Management 72

DB2 UDB V8.2 SQL 101102 INSERT 201202203 INSERT cibm() Information Management 73 DB2 UDB V8.2 SQL Blocking NO Blocking ALL 201SAVEPOINTINSERT DB2DELETE Blocking NO ROLLBACK TO SAVEPOINTOPEN/FETCH ROLLBACK cibm() Information Management 74

DB2 UDB V8.2 SQL cibm() Information Management 75 DB2 UDB V8.2 SQL cibm() Information Management 76

cibm() Information Management DB2 UDB V8.2 SQL cibm() Information Management 78

cibm() Information Management DB2 UDB V8.2 SQL cibm() Information Management 80

DB2 UDB V8.2 SQL cibm() Information Management 81 DB2 UDB V8.2 SQL cibm() Information Management 82

DB2 UDB V8.2 SQL cibm() Information Management 83 DB2 UDB V8.2 SQL cibm() Information Management 84

DB2 UDB V8.2 SQL cibm() Information Management 85 DB2 UDB V8.2 SQL LOCKTIMEOUT CURRENT LOCKTIMEOUTDBLOCKTIMEOUT CURRENT LOCKTIMEOUTSET CURRENT LOCK TIMEOUT V8.130000V8.232767 db2 SET LOCK TIMEOUT WAIT db2 SET LOCK TIMEOUT NOT WAIT db2 SET LOCK TIMEOUT NULL db2 SET LOCK TIMEOUT integer db2 SET LOCK TIMEOUT -1 0SQL0911 DBLOCKTIMEOUT LOCKTOMEOUT-132767 LOCKTIMEOUT-132767 NULLDB InformixDB2 InformixSET CURRENT LOCK MODE TO DB2 UDB V8.2SET CURRENT LOCK TIMEOUT Informix SET CURRENT LOCK MODE TO db2 SET LOCK TIMEOUT WAIT db2 SET LOCK TIMEOUT NOT WAIT db2 SET LOCK TIMEOUT WAIT 30-1 0 30 cibm() Information Management 86

DB2 UDB V8.2 SQL LOCK TEST1 SET CURRENT LOCKTIMEOUT= 0 SELECT * FROM TEST1 test1lock db2 +C LOCK TABLE TEST1 IN EXCLUSIVE MODE CURRENT LOCK TIMEOUT db2 SET CURRENT LOCK TIMEOUT 0 SQL0911N LOCKTEST1SELECT db2 "SELECT * FROM TEST1 SQL0911N "68" SQLSTATE=40001 cibm() Information Management 87 DB2 UDB V8.2 SQL INFORMIXSET LOCK MODECURRENT LOCK TIMEOUT $ db2 GET DB CFG FOR SAMPLE FIND LOCKTIMEOUT () (LOCKTIMEOUT) = -1 LOCKTIMEOUT -1 $ db2 SET LOCK MODE TO WAIT 10 $ db2 VALUES CURRENT LOCK TIMEOUT 1 ----------- 10 1 record(s) selected. INFORMIX LOCKTIMEOUT 10 NULLDB $ db2 SET CURRENT LOCK TIMEOUT NULL $ db2 VALUES CURRENT LOCK TIMEOUT 1 ----------- -1 1 record(s) selected. NULL DB cibm() Information Management 88

DB2 UDB V8.2 SQL LOCKTIMEOUTdb2cli.ini LOCKTIMEOUT-1 $ db2 GET DB CFG FOR SAMPLE FIND "LOCKTIMEOUT" () (LOCKTIMEOUT) = -1 EMPLOYEE $ db2 +c LOCK TABLE EMPLOYEE IN EXCLUSIVE MODE JavaLOCKTIMEOUT5EMPLOYEE 5SQL0911 Execute Statement: set lock mode to 5 Execute statement values(current lock timeout) Results: special register values ----------------------- 5 sec : locktimeout 5 VALUE SELECT 5 SQL0911N SELECT * FROM EMPLOYEE WHERE EMPNO < '000100' ***SQL Exception*** [IBM][CLI Driver][DB2/NT] SQL0911N "68" SQLSTATE=40001 cibm() Information Management 89 DB2 UDB V8.2 SQL //set current lock timeout 5 stmt.executeupdate("set current lock timeout 5"); System.out.println(" Execute statement values(current lock timeout) "); ResultSet rs = stmt.executequery(" values(current lock timeout) "); System.out.println(); System.out.println(" Results: n" + " special register values n" + " -----------------------"); int locktimeout = 0; while (rs.next()) { locktimeout = rs.getint(1); System.out.println(" " + locktimeout + " sec : locktimeout n n"); //System.out.println(" " + Data.format(locktimeout, 8)); } cibm() Information Management 90

DB2 UDB V8.2 SQL properties put System.out.println("About to connect to "+url); properties.put("currentlocktimeout", "-1"); System.out.println("CurrentLockTimeout property is -1"); connect_to_db(con,properties,url); properties.put("currentlocktimeout", "32676"); System.out.println("CurrentLockTimeout property is 32676"); connect_to_db(con,properties,url); properties.put("currentlocktimeout", "40"); System.out.println("CurrentLockTimeout property is 40"); connect_to_db(con,properties,url); properties.put("currentlocktimeout", "0"); System.out.println("CurrentLockTimeout property is 0"); cibm() Information Management 91 DB2 UDB V8.2 SQL cibm() Information Management 92

DB2 UDB V8.2 SQL SET LOCK TIMEOUT, Nick NameJOINNick NameSQLCURRENT LOCK TIMEOUT cibm() Information Management 93 DB2 UDB V8.2 SQL cibm() Information Management 94

cibm() Information Management DB2 UDB V8.2 SQL cibm() Information Management 96

DB2 UDB V8.2 SQL cibm() Information Management 97 DB2 UDB V8.2 SQL cibm() Information Management 98

DB2 UDB V8.2 SQL CREATE TABLE T1 (C1 INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), C2 DOUBLE, C3 DOUBLE GENERATED AS (C1+C2), C4 INT GENERATED AS (CASE WHEN C1>C2 THEN 1 ELSE NULL END)); INSERT INTO T1 VALUES (DEFAULT, 2, DEFAULT, DEFAULT) cibm() Information Management 99 DB2 UDB V8.2 SQL (re-write) re-write SELECT * FROM T1 WHERE C1+C2 = 5 SELECT Q1.C1 AS "C1", Q1.C2 AS "C2", Q1.C3 AS "C3", Q1.C4 AS "C4" FROM DB2.T1 AS Q1 WHERE (Q1.C3 = +5.00000000000000E+000) cibm() Information Management 100

DB2 UDB V8.2 SQL cibm() Information Management 101 DB2 UDB V8.2 SQL INSERTWITH DEFAULT VALUESDEFAULT INSERT INTO t1 VALUES(DEFAULT,2,DEFAULT,DEFAULT) INSERT INTO t1 (C2) VALUES(3) generation-expression UPDATE T1 SET C2=5 WHERE C2=3 C2=3 C2 C3 DB2 INSERT INTO t1 VALUES(1,2,3,NULL) UPDATE t1 SET C3 = 3.0 WHERE C1 = 1 SQL0798N GENERATED ALWAYS "C3" SQLSTATE=428C9 SQL0798N(428C9) cibm() Information Management 102

DB2 UDB V8.2 SQL cibm() Information Management 103 DB2 UDB V8.2 SQL generated-expression CREATE TABLE GENE_TEST (C1 INT NOT NULL, C2 DOUBLE DEFAULT 1.1, C3 DOUBLE NOT NULL, C4 INT) INSERT INTO GENE_TEST (C1,C3,C4)VALUES(1,1.5,9) INSERT INTO GENE_TEST VALUES(5, DEFAULT, 1.3, 5) SET INTEGRITY OFF T1 SET INTEGRITY OFF generated-expressionsql20054n SET INTEGRITY FOR GENE_TEST OFF cibm() Information Management 104

DB2 UDB V8.2 SQL generated-expression C3C1+C2generated-expression ALTER TABLE GENE_TEST ALTER COLUMN C3 SET GENERATED ALWAYS AS(C1+C2) C4ALTERC1>C21nullgenerated-expression ALTER TABLE GENE_TEST ALTER COLUMN C4 SET GENERATED ALWAYS AS(CASE WHEN C1>C2 THEN 1 ELSE NULL END) SELECTSQL0668N SQL0668N "1" "MAKIKO.GENE_TEST" SQLSTATE=57016 ON SET INTEGRITY FOR GENE_TEST IMMEDIATE CHECKED FORCE GENERATED C3C4 GENERATED cibm() Information Management 105 DB2 UDB V8.2 SQL generated-expression generated-expression generated-expression ALTER TABLE GENE_TEST ALTER COLUMN C3 DROP EXPRESSION INSERT INSERT INTO GENE_TEST (C1)VALUES(10) C3generated-expression NULL cibm() Information Management 106

DB2 UDB V8.2 SQL ID IDNOT NULLC1NOT NULL C1IDID=20ID ALTER TABLE GENE_TEST ALTER COLUMN C1 SET GENERATED ALWAYS AS IDENTITY(START WITH 20) INSERT INTO GENE_TEST (C2)VALUES(5.1); INSERT INTO GENE_TEST (C1,C2)VALUES(DEFAULT, 5.1); C1ID cibm() Information Management 107 DB2 UDB V8.2 SQL GENERATED ALWAYS GENERATED BY DEFAULT GENERATED ALWAYS GENERATED DEFAULT GENERATED ALWAYS DB2 GENERATED BY DEFAULTDB2 IDC1GENERATED ALWAYS AS IDENTITY GENERATED BY DEFAULT AS IDENTITY ID=30C1ID ALTER TABLE GENE_TEST ALTER COLUMN C1 SET GENERATED BY DEFAULT RESTART WITH 30 C11C1 INSERT INTO GENE_TEST (C1,C2)VALUES(25,6.1) ID30 C1 25 cibm() Information Management 108

DB2 UDB V8.2 SQL GENERATED ALWAYS GENERATED BY DEFAULT C11C130IDINSERTC1 31 INSERT INTO GENE_TEST (C2)VALUES(7.1),(7.1) C1ID30 cibm() Information Management 109 DB2 UDB V8.2 SQL ID C1IDC1NOT NULLINT ALTER TABLE GENE_TEST ALTER COLUMN C1 DROP IDENTITY C1 INSERT INTO GENE_TEST (C2)VALUES(8.1) C1 WITH DEFAULT 100 NOT NULL 0 cibm() Information Management 110

DB2 UDB V8.2 SQL C2 ALTER TABLE GENE_TEST ALTER COLUMN C2 DROP DEFAULT C2C2NULL INSERT INTO GENE_TEST (C1,C2)VALUES(40,DEFAULT) C2 NULL cibm() Information Management 111 DB2 UDB V8.2 SQL C1C3GENERATEDC110C3C2*2 CREATE TABLE GENE_TEST2 ( C1 INTEGER NOT NULL GENERATED ALWAYS AS (10), C2 DOUBLE, C3 INTEGER GENERATED ALWAYS AS (INTEGER(C2)*2) NOT NULL, C4 INTEGER ) INSERT INTO GENE_TEST2 (C2)VALUES(1.1),(5.1) C3generated-expressionC3ID generated-expression ID ALTER TABLE GENE_TEST2 ALTER COLUMN C3 DROP EXPRESSION SET GENERATED BY DEFAULT AS IDENTITY (START WITH 1) INSERT INTO GENE_TEST2 (C2)VALUES(10.1),(15.1)" C3generatedexpression C2*2 C3ID ID cibm() Information Management 112

DB2 UDB V8.2 114

DB2 UDB V8.2 115 DB2 UDB V8.2 116

DB2 UDB V8.2 SQL SELECT C1, C2 FROM TABLE1 WHERE C1= NewYork AND C2 <= 10 (TABLE1) A or B RUNSTATS LOADSTATISTIC YES SQL UPDATE UDF 117 DB2 UDB V8.2 118

DB2 UDB V8.2 strcpy (str,"select COL2 FROM T1 WHERE C1 BETWEEN? AND?"); EXEC SQL PREPARE st1 FROM :str; EXEC SQL DECLARE cur1 CURSOR FOR st1; val1=100; val2=200; EXEC SQL OPEN cur1 using :val1, :val2; EXEC SQL FETCH cur1 INTO :val3; 119 DB2 UDB V8.2 120

DB2 UDB V8.2 EXEC SQL BEGIN DECLARE SECTION; short var1; short var2; EXEC SQL END DECLARE SECTION; val1=100; EXEC SQL SELECT COL2 INTO :val2 FROM T1 WHERE COL1< :var1; 121 DB2 UDB V8.2 122

DB2 UDB V8.2 123 DB2 UDB V8.2 T110000 C111000 C2110000 SELECT FROM T1 WHERE COL1 = AND COL2 =100 COL1<=1 10 COL2<=100 100 COL1 X1 x1 SELECT FROM T1 WHERE COL1 = 10 AND COL2 = 10 COL1 <= 10 COL2 <= 10 100 10 COL2 X2 x2 124

DB2 UDB V8.2 125 DB2 UDB V8.2 C1 126

DB2 UDB V8.2 C1 =5C2=10000 C210.000 127 DB2 UDB V8.2 128

DB2 UDB V8.2 129 DB2 UDB V8.2 130

DB2 UDB V8.2 REOPT DB2 NONE SQL ONCE 7 SQL 7 ALWAYS 7 SQL REOPT / NOREOPT VARS REOPT ALWAYS REOPT NONE DB2 DB2 for OS/390 DB2 for OS/390 131 DB2 UDB V8.2 SYSCAT.PACKAGESREOPTVAR SYSCAT.PACKAGES REOPTVAR REOPT NONE = N REOPT ONCE = O REOPT ALWAYS = A 132

DB2 UDB V8.2 133 DB2 UDB V8.2 134

DB2 UDB V8.2 135 DB2 UDB V8.2 DB2SimpleDataSource db2ds = new DB2SimpleDataSource(); db2ds.setdatabasename("sample"); db2ds.setuser("user82"); db2ds.setpassword("stingerws"); db2ds.setjdbccollection("reoptset"); con = db2ds.getconnection(); 136

DB2 UDB V8.2 137 DB2 UDB V8.2 1 2 REOPTVAR ---------- ---------- -------- REOPTA SYSLH100 A REOPTA SYSLH101 A REOPTA SYSLH102 A REOPTA SYSLH200 A REOPTA SYSLH201 A REOPTA SYSLH202 A REOPTA SYSLH300 A REOPTA SYSLH301 A REOPT ALWAYS 138

DB2 UDB V8.2 C1<=5 139 DB2 UDB V8.2 Rows written: 0 C2<=50 50 140

DB2 UDB V8.2 1 2 REOPTVAR ---------- ---------- -------- REOPTO SYSLH100 O REOPTO SYSLH101 O REOPTO SYSLH102 O REOPTO SYSLH200 O REOPTO SYSLH201 O REOPTO SYSLH202 O REOPTO SYSLH300 O REOPT ONCE 141 DB2 UDB V8.2 C1<=5 142

DB2 UDB V8.2 C1<=1000 10000 143 DB2 UDB V8.2 3. FLUSH PACKAGE CACHE DYNMIC C2<=50 50 144

DB2 UDB V8.2 145 DB2 UDB V8.2 146

DB2 UDB V8.2 NEW 147 DB2 UDB V8.2 148

DB2 UDB V8.2 EXPLAIN EXPAINSQL 149 DB2 UDB V8.2 150

DB2 UDB V8.2 151 DB2 UDB V8.2 152

DB2 UDB V8.2 153 DB2 UDB V8.2 WITH REOPT ONCE WITH REOPT ONCE 154

DB2 UDB V8.2 155 DB2 UDB V8.2 156

DB2 UDB V8.2 157 DB2 UDB V8.2 SQL0020W BIND () REOPT" 158

cibm() Information Management DB2 UDB V8.2 SQL cibm() Information Management 160

DB2 UDB V8.2 SQL cibm() Information Management 161 DB2 UDB V8.2 SQL cibm() Information Management 162

DB2 UDB V8.2 SQL Select for update Update Select for update Update U 10 AAAAA 20 BBBBB 30 CCCCC 40 DDDDD U cibm() Information Management 163 DB2 UDB V8.2 SQL cibm() Information Management 164

DB2 UDB V8.2 SQL cibm() Information Management 165 DB2 UDB V8.2 SQL cibm() Information Management 166

DB2 UDB V8.2 SQL cibm() Information Management 167 DB2 UDB V8.2 SQL cibm() Information Management 168

DB2 UDB V8.2 SQL cibm() Information Management 169 DB2 UDB V8.2 SQL cibm() Information Management 170

DB2 UDB V8.2 SQL cibm() Information Management 171 DB2 UDB V8.2 SQL cibm() Information Management 172

DB2 UDB V8.2 SQL cibm() Information Management 173 DB2 UDB V8.2 SQL cibm() Information Management 174

DB2 UDB V8.2 SQL select c3,c5 from t1,t2 where t1.c1=a and t1.c2=t2.c4 with rs use and keep update locks C1 C4 T1 T2 U U U U U U cibm() Information Management 175 DB2 UDB V8.2 SQL cibm() Information Management 176

DB2 UDB V8.2 SQL cibm() Information Management 177 DB2 UDB V8.2 SQL cibm() Information Management 178

DB2 UDB V8.2 SQL cibm() Information Management 179 DB2 UDB V8.2 SQL cibm() Information Management 180

DB2 UDB V8.2 SQL cibm() Information Management 181 DB2 UDB V8.2 SQL cibm() Information Management 182

DB2 UDB V8.2 SQL cibm() Information Management 183 DB2 UDB V8.2 SQL cibm() Information Management 184