Db2 12 for Z/OS: ODBC Guide and Reference Chapter 1
Total Page:16
File Type:pdf, Size:1020Kb
Db2 12 for z/OS ODBC Guide and Reference IBM SC27-8856-02 Notes Before using this information and the product it supports, be sure to read the general information under "Notices" at the end of this information. Subsequent editions of this PDF will not be delivered in IBM Publications Center. Always download the latest edition from PDF format manuals for Db2 12 for z/OS (Db2 for z/OS Knowledge Center). 2020-11-30 edition This edition applies to Db2® 12 for z/OS® (product number 5650-DB2), Db2 12 for z/OS Value Unit Edition (product number 5770-AF3), and to any subsequent releases until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. Specific changes are indicated by a vertical bar to the left of a change. A vertical bar to the left of a figure caption indicates that the figure has changed. Editorial changes that have no technical significance are not noted. © Copyright International Business Machines Corporation 1997, 2020. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this information.......................................................................................... ix Who should read this information................................................................................................................x Db2 Utilities Suite for z/OS...........................................................................................................................x Terminology and citations............................................................................................................................x Accessibility features for Db2 12 for z/OS..................................................................................................xi How to send your comments...................................................................................................................... xi How to read syntax diagrams......................................................................................................................xi Chapter 1. Introduction to Db2 ODBC..................................................................... 1 Db2 ODBC background information............................................................................................................ 1 Differences between Db2 ODBC and ODBC 3.0.................................................................................... 2 Db2 ODBC support for ODBC features...................................................................................................2 Differences between Db2 ODBC and embedded SQL................................................................................ 4 Advantages of using Db2 ODBC...................................................................................................................7 Considerations for choosing between SQL and Db2 ODBC........................................................................ 7 Chapter 2. Conceptual view of a Db2 ODBC application...........................................9 Initialization and termination of an ODBC program..................................................................................10 Handles.................................................................................................................................................10 ODBC connection model...................................................................................................................... 11 How to specify the connection type.................................................................................................... 12 How to connect to one or more data sources..................................................................................... 13 Transaction processing in Db2 ODBC....................................................................................................... 14 Statement handle allocation................................................................................................................15 Preparation and execution of SQL statements....................................................................................16 How an ODBC program processes results...........................................................................................18 Commit and rollback in Db2 ODBC......................................................................................................21 Function for freeing statement handles.............................................................................................. 22 Diagnostics.................................................................................................................................................23 Function return codes.......................................................................................................................... 23 SQLSTATEs for ODBC error reporting.................................................................................................. 24 SQLCA retrieval in an ODBC application..............................................................................................25 Data types and data conversion................................................................................................................ 25 C and SQL data types........................................................................................................................... 25 C data types that do not map to SQL data types................................................................................. 31 Data conversion....................................................................................................................................32 Characteristics of string arguments.......................................................................................................... 34 Length of string arguments.................................................................................................................. 34 Nul-termination of strings....................................................................................................................35 String truncation...................................................................................................................................35 Interpretation of strings.......................................................................................................................35 Functions for querying environment and data source information..........................................................35 Chapter 3. Configuring Db2 ODBC and running sample applications...................... 39 Running the SMP/E jobs for Db2 ODBC installation..................................................................................39 The Db2 ODBC run time environment.......................................................................................................39 Connectivity requirements...................................................................................................................40 Extra performance linkage...................................................................................................................41 64-bit ODBC driver............................................................................................................................... 41 Db2 ODBC run time environment setup....................................................................................................41 iii Binding DBRMs to create packages.....................................................................................................42 Binding the application plan................................................................................................................ 44 Setting up Db2 ODBC for the z/OS UNIX environment....................................................................... 45 Overview of preparing and executing a Db2 ODBC application............................................................... 46 Db2 ODBC application requirements........................................................................................................ 47 Preparing and executing an ODBC application......................................................................................... 48 Compiling an ODBC application........................................................................................................... 49 Prelinking and link-editing an ODBC application.................................................................................52 Executing an ODBC application........................................................................................................... 55 How to define a subsystem to Db2 ODBC.................................................................................................56 Db2 ODBC initialization file........................................................................................................................57 How to use the initialization file...........................................................................................................57 Db2 ODBC initialization keywords....................................................................................................... 59 Database metadata stored procedures.................................................................................................... 80 Migrating to the Db2 12 ODBC driver........................................................................................................80