SAS/ACCESS 9.1.3 Supplement for DB2 under UNIX and PC Hosts ...

53 downloads 46 Views 963KB Size Report
The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2006. SAS/ACCESS® 9.1.3 Supplement for DB2 under UNIX and PC Hosts ...
SAS/ACCESS 9.1.3 Supplement for DB2 under UNIX and PC Hosts ®

SAS/ACCESS for Relational Databases Second Edition

The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2006. SAS/ACCESS ® 9.1.3 Supplement for DB2 under UNIX and PC Hosts (SAS/ACCESS Relational Databases), Second Edition. Cary, NC: SAS Institute Inc. SAS/ACCESS® 9.1.3 Supplement for DB2 under UNIX and PC Hosts (SAS/ACCESS Relational Databases), Second Edition Copyright © 2006, SAS Institute Inc., Cary, NC, USA ISBN-13: 978-1-59047-865-3 ISBN-10: 1-59047-865-7 All rights reserved. Produced in the United States of America. For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc. For a Web download or e-book: Your use of this publication shall be governed by the terms established by the vendor at the time you acquire this publication. U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of this software and related documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in FAR 52.227-19 Commercial Computer Software-Restricted Rights (June 1987). SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513. 1st printing, February 2006 SAS Publishing provides a complete selection of books and electronic products to help customers use SAS software to its fullest potential. For more information about our e-books, e-learning products, CDs, and hard-copy books, visit the SAS Publishing Web site at support.sas.com/pubs or call 1-800-727-3228. SAS® and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies.

Contents Chapter 1

4 SAS/ACCESS for DB2 under UNIX and PC Hosts

1

Introduction to the SAS/ACCESS Interface to DB2 under UNIX and PC Hosts LIBNAME Statement Specifics for DB2 under UNIX and PC Hosts 2 Data Set Options for DB2 under UNIX and PC Hosts 5 Pass-Through Facility Specifics for DB2 under UNIX and PC Hosts Autopartitioning Scheme for DB2 under UNIX and PC Hosts 8 Temporary Table Support for DB2 under UNIX and PC Hosts 11 DBLOAD Procedure Specifics for DB2 under UNIX and PC Hosts Passing SAS Functions to DB2 under UNIX and PC Hosts 14 Passing Joins to DB2 under UNIX and PC Hosts 15 Locking for DB2 under UNIX and PC Hosts Interface DB2 under UNIX and PC Hosts Bulk Loading 17 DB2 under UNIX and PC Hosts Naming Conventions Data Types for DB2 under UNIX and PC Hosts 20

Appendix 1

4 Recommended Reading

Recommended Reading

Glossary Index

27 33

25

25

15 19

7

12

2

iv

1

CHAPTER

1 SAS/ACCESS for DB2 under UNIX and PC Hosts Introduction to the SAS/ACCESS Interface to DB2 under UNIX and PC Hosts LIBNAME Statement Specifics for DB2 under UNIX and PC Hosts 2 Arguments 2 DB2 UNIX/PC LIBNAME Statement Example 5 Data Set Options for DB2 under UNIX and PC Hosts 5 Pass-Through Facility Specifics for DB2 under UNIX and PC Hosts 7 Examples 7 Autopartitioning Scheme for DB2 under UNIX and PC Hosts 8 Overview 8 Autopartitioning Restrictions 8 Nullable Columns 8 Using WHERE Clauses 8 Using DBSLICEPARM= 9 Using DBSLICE= 9 Configuring DB2 EEE Nodes on Physically Partitioned Databases 10 Temporary Table Support for DB2 under UNIX and PC Hosts 11 Establishing a Temporary Table 11 Terminating a Temporary Table 11 Examples 11 DBLOAD Procedure Specifics for DB2 under UNIX and PC Hosts 12 Examples 13 Passing SAS Functions to DB2 under UNIX and PC Hosts 14 Passing Joins to DB2 under UNIX and PC Hosts 15 Locking for DB2 under UNIX and PC Hosts Interface 15 DB2 under UNIX and PC Hosts Bulk Loading 17 Maximizing Load Performance for DB2 under UNIX and PC Hosts 18 Examples 19 DB2 under UNIX and PC Hosts Naming Conventions 19 Data Types for DB2 under UNIX and PC Hosts 20 String Data 20 Numeric Data 21 Dates, Times, and Timestamps 21 DB2 Null and Default Values 22 LIBNAME Statement Data Conversions 22 DBLOAD Procedure Data Conversions 23

2

2

Introduction to the SAS/ACCESS Interface to DB2 under UNIX and PC Hosts

4

Chapter 1

Introduction to the SAS/ACCESS Interface to DB2 under UNIX and PC Hosts This document includes details only about the SAS/ACCESS interface to DB2 under UNIX and PC Hosts. It should be used as a supplement to the generic SAS/ACCESS documentation, SAS/ACCESS for Relational Databases: Reference.

LIBNAME Statement Specifics for DB2 under UNIX and PC Hosts This section describes the LIBNAME statement as supported by the interface to DB2 under UNIX and PC hosts. For a complete description of this feature, see the LIBNAME statement section in SAS/ACCESS for Relational Databases: Reference. The DB2 under UNIX and PC hosts specific syntax for the LIBNAME statement is as follows: LIBNAME libref db2 ;

Arguments libref is any SAS name that serves as an alias to associate SAS with a database, schema, server, or group of tables and views. db2 is the SAS/ACCESS engine name for the interface to DB2 under UNIX and PC hosts. connection-options provide connection information and control how SAS manages the timing and concurrence of the connection to the DBMS. There are several ways to connect to DB2 when you are using the LIBNAME statement. Use only one of the following methods for each connection since they are mutually exclusive: 3 specify USER=, PASSWORD=, and DATASRC= 3 specify COMPLETE= 3 specify NOPROMPT= 3 specify PROMPT= 3 specify READBUFF= 3 specify REQUIRED=. Definitions of these connection options are provided below. USER=user-name enables you to connect to a DB2 database with a user ID that is different from the default ID. USER= is optional. If you specify USER=, you must also specify PASSWORD=. If USER= is omitted, your default user ID for your operating environment is used. PASSWORD=password specifies the DB2 password that is associated with your DB2 user ID. PASSWORD= is optional. If you specify USER=, you must specify PASSWORD=. DATASRC=data-source-name

SAS/ACCESS for DB2 under UNIX and PC Hosts

4

Arguments

3

specifies the DB2 data source or database to which you want to connect. DATASRC= is optional. If you omit it, you connect by using a default environment variable. DSN= and DATABASE= are aliases for this option. COMPLETE=CLI-connection-string specifies connection information for your data source or database for PCs only. Separate multiple options with a semicolon. When a successful connection is made, the complete connection string is returned in the SYSDBMSG macro variable. If you do not specify enough correct connection options, you are prompted with a dialog box that displays the values from the COMPLETE= connection string. You can edit any field before you connect to the data source. This option is not available on UNIX platforms. See your DB2 documentation for more details. NOPROMPT=CLI-connection-string specifies connection information for your data source or database. Separate multiple options with a semicolon. If you do not specify enough correct connection options, an error is returned (no dialog box is displayed). PROMPT= CLI-connection-string specifies connection information for your data source or database for PCs only. Separate multiple options with a semicolon. When a successful connection is made, the complete connection string is returned in the SYSDBMSG macro variable. PROMPT= does not immediately attempt to connect to the DBMS. Instead, it displays a dialog box that contains the values that you entered in the PROMPT= connection string. You can edit values or enter additional values in any field before you connect to the data source. This option is not available on UNIX platforms. READBUFF= number-of-rows READBUFF is used to control the number of rows that are fetched during each read operation. By default, an optimal value is calculated by the SAS/ ACCESS to DB2 engine based on the row length of your data. You should not have to specify this option unless you suspect problems related to fetching multiple rows from the DB2 database. REQUIRED=CLI-connection-string specifies connection information for your data source or database for PCs only. Separate multiple options with a semicolon. When a successful connection is made, the complete connection string is returned in the SYSDBMSG macro variable. If you do not specify enough correct connection options, a dialog box prompts you for the connection options. REQUIRED= only allows you to modify required fields in the dialog box. This option is not available on UNIX platforms. LIBNAME-options define how DBMS objects are processed by SAS. Some LIBNAME options can enhance performance; others determine locking or naming behavior. The following table describes which LIBNAME options are supported for DB2 under UNIX and PC hosts, and presents default values where applicable. See the section about the LIBNAME statement in SAS/ACCESS for Relational Databases: Reference for detailed information about these options.

4

Arguments

4

Chapter 1

Table 1.1 SAS/ACCESS LIBNAME Options for DB2 under UNIX and PC Hosts

Option

Default Value

ACCESS=

none

AUTOCOMMIT=

varies with transaction type

CONNECTION=

SHAREDREAD

CONNECTION_GROUP=

none

CURSOR_TYPE=

DYNAMIC

DBCOMMIT=

1000 (insert); 0 (update); 10000 (bulk load)

DBCONINIT=

none

DBCONTERM=

none

DBCREATE_TABLE_OPTS=

none

DBGEN_NAME=

DBMS

DBINDEX=

YES

DBLIBINIT=

none

DBLIBTERM=

none

DBMAX_TEXT=

1024

DBNULLKEYS=

YES

DBPROMPT=

NO

DBSLICEPARM=

THREADED_APPS,2 or 3

DEFER=

NO

DIRECT_EXE=

none

DIRECT_SQL=

YES

IGNORE_ READ_ONLY_COLUMNS=

NO

IN=

none

INSERTBUFF=

automatically calculated based upon row length

MULTI_DATASRC_OPT=

NONE

PRESERVE_COL_NAMES=

NO (see “DB2 under UNIX and PC Hosts Naming Conventions” on page 19)

PRESERVE_TAB_NAMES=

NO (see “DB2 under UNIX and PC Hosts Naming Conventions” on page 19)

QUERY_TIMEOUT=

0

READBUFF=

automatically calculated based upon row length

READ_ISOLATION_LEVEL=

set by the user in the DB2Cli.ini file (see “Locking for DB2 under UNIX and PC Hosts Interface” on page 15)

READ_LOCK_TYPE=

ROW

REREAD_EXPOSURE=

NO

SCHEMA=

your user ID

SPOOL=

YES

SAS/ACCESS for DB2 under UNIX and PC Hosts

4

Data Set Options for DB2 under UNIX and PC Hosts

Option

Default Value

SQL_FUNCTIONS=

NONE

STRINGDATES=

NO

UPDATE_ISOLATION_LEVEL=

CS (see “Locking for DB2 under UNIX and PC Hosts Interface” on page 15)

UPDATE_LOCK_TYPE=

ROW

UTILCONN_TRANSIENT=

YES

5

DB2 UNIX/PC LIBNAME Statement Example In the following example, the libref MyDBLib uses the DB2 engine and the NOPROMPT= option to connect to a DB2 database. PROC PRINT is used to display the contents of the DB2 table Customers. libname mydblib db2 noprompt="dsn=userdsn;uid=testuser;pwd=testpass;"; proc print data=mydblib.customers; where state=’CA’; run;

Data Set Options for DB2 under UNIX and PC Hosts The following table describes the data set options that are supported for DB2 under UNIX and PC hosts, and provides default values where applicable. See the section about data set options in SAS/ACCESS for Relational Databases: Reference for detailed information about these options. Table 1.2 SAS/ACCESS Data Set Options for DB2 under UNIX and PC Hosts Option

Default Value

BL_CODEPAGE=

the window’s codepage ID

BL_COPYLOCATION=

none

BL_DATAFILE=

the current directory

BL_DELETE_DATAFILE=

YES

BL_INDEXING_MODE=

AUTOSELECT

BL_LOAD_REPLACE=

NO

BL_LOG=

the current directory

BL_METHOD=

none

BL_OPTIONS=

none

BL_RECOVERABLE=

NO

BL_REMOTEFILE=

none

BL_SERVER_DATAFILE=

same as BL_DATAFILE

BL_WARNING_COUNT=

2147483646

6

Data Set Options for DB2 under UNIX and PC Hosts

4

Chapter 1

Option

Default Value

BULKLOAD=

NO

CURSOR TYPE=

LIBNAME option setting

DBCOMMIT=

LIBNAME option setting

DBCONDITION=

none

DBCREATE_TABLE_OPTS=

LIBNAME option setting

DBFORCE=

NO

DBGEN_NAME=

DBMS

DBINDEX=

LIBNAME option setting

DBKEY=

none

DBLABEL=

NO

DBMASTER=

none

DBMAX_TEXT=

1024

DBNULL=

_ALL_=YES

DBNULLKEYS=

LIBNAME option setting

DBPROMPT=

LIBNAME option setting

DBSASTYPE=

see “Data Types for DB2 under UNIX and PC Hosts” on page 20

DBSLICE=

none

DBSLICEPARM=

THREADED_APPS,2 or 3

DBTYPE=

see “Data Types for DB2 under UNIX and PC Hosts” on page 20

ERRLIMIT=

1

IGNORE_ READ_ONLY_COLUMNS=

NO

IN=

LIBNAME option setting

INSERTBUFF=

LIBNAME option setting

NULLCHAR=

SAS

NULLCHARVAL=

a blank character

PRESERVE_COL_NAMES=

LIBNAME option setting

QUERY_TIMEOUT=

LIBNAME option setting

READ_ISOLATION_LEVEL=

LIBNAME option setting

READ_LOCK_TYPE=

LIBNAME option setting

READBUFF=

LIBNAME option setting

SASDATEFMT=

none

SCHEMA=

LIBNAME option setting

SAS/ACCESS for DB2 under UNIX and PC Hosts

Option

Default Value

UPDATE_ISOLATION_LEVEL=

LIBNAME option setting

UPDATE_LOCK_TYPE=

LIBNAME option setting

4

Examples

7

Pass-Through Facility Specifics for DB2 under UNIX and PC Hosts See the section about the Pass-Through Facility in SAS/ACCESS for Relational Databases: Reference for general information about this feature. The Pass-Through Facility specifics for DB2 under UNIX and PC Hosts are as follows: 3 The dbms-name is DB2. 3 The CONNECT statement is required. 3 You can connect to only one DB2 database at a time. However, you can use multiple CONNECT statements to connect to multiple DB2 data sources by using the alias argument to distinguish your connections. 3 The database-connection-arguments for the CONNECT statement are identical to its LIBNAME connection options. 3 The following LIBNAME options are available with the CONNECT statement: AUTOCOMMIT= CURSOR_TYPE= QUERY_TIMEOUT= READBUFF= READ_ISOLATION_LEVEL= See the section about the LIBNAME statement in SAS/ACCESS for Relational Databases: Reference for information about these options.

Examples The following example connects to the SAMPLE database and sends it two EXECUTE statements to process. proc sql; connect to db2 (database=sample); execute (create view sasdemo.whotookorders as select ordernum, takenby, firstname, lastname, phone from sasdemo.orders, sasdemo.employees where sasdemo.orders.takenby= sasdemo.employees.empid) by db2; execute (grant select on sasdemo.whotookorders to testuser) by db2; disconnect from db2; quit;

The following example connects to the SAMPLE database by using an alias (DB1) and performs a query, shown in italic type, on the SASDEMO.CUSTOMERS table.

8

Autopartitioning Scheme for DB2 under UNIX and PC Hosts

4

Chapter 1

proc sql; connect to db2 as db1 (database=sample); select * from connection to db1 (select * from sasdemo.customers where customer like ’1%’); disconnect from db1; quit;

Autopartitioning Scheme for DB2 under UNIX and PC Hosts See the section about threaded reads in SAS/ACCESS for Relational Databases: Reference for general information about this feature.

Overview The autopartitioning method available for the SAS/ACCESS interface to DB2 for UNIX and PC hosts is a MOD function method as described in the section about autopartitioning techniques in SAS/ACCESS for Relational Databases: Reference.

Autopartitioning Restrictions The interface to DB2 under UNIX and PC hosts restricts which columns can be used for the partitioning column during the autopartitioning phase. Columns are partitioned as follows:

3 INTEGER and SMALLINT columns are given preference. 3 The other DB2 numeric columns may be used for partitioning, provided that the precision minus the scale of the column is between 0 and 10. That is, 0

Suggest Documents