Embedded SQL Programming

Embedded SQL Programming

IBM i 7.3 Database Embedded SQL programming IBM Note Before using this information and the product it supports, read the information in “Notices” on page 199. This edition applies to IBM i 7.3 (product number 5770-SS1) and to all subsequent releases and modifications until otherwise indicated in new editions. This version does not run on all reduced instruction set computer (RISC) models nor does it run on CISC models. This document may contain references to Licensed Internal Code. Licensed Internal Code is Machine Code and is licensed to you under the terms of the IBM License Agreement for Machine Code. © Copyright International Business Machines Corporation 1998, 2015. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Embedded SQL programming.................................................................................1 What's new for IBM i 7.3..............................................................................................................................1 PDF file for Embedded SQL programming...................................................................................................2 Common concepts and rules for using embedded SQL..............................................................................2 Writing applications that use SQL.......................................................................................................... 2 Using host variables in SQL statements.................................................................................................3 Assignment rules for host variables in SQL statements.................................................................. 4 Indicator variables in applications that use SQL..............................................................................4 Indicator variables used with host structures............................................................................5 Indicator variables used to assign special values...................................................................... 5 Handling SQL error return codes using the SQLCA................................................................................7 Using the SQL diagnostics area..............................................................................................................7 Updating applications to use the SQL diagnostics area...................................................................8 IBM i programming model ............................................................................................................... 8 Additional notes on using the SQL diagnostics area........................................................................8 Example: SQL routine exception.......................................................................................................9 Example: Logging items from the SQL diagnostics area..................................................................9 Handling exception conditions with the WHENEVER statement........................................................ 10 Coding SQL statements in C and C++ applications...................................................................................11 Defining the SQL communication area in C and C++ applications that use SQL................................ 11 Defining SQL descriptor areas in C and C++ applications that use SQL............................................. 13 Embedding SQL statements in C and C++ applications that use SQL................................................ 14 Comments in C and C++ applications that use SQL.......................................................................15 Continuation for SQL statements in C and C++ applications that use SQL...................................15 Including code in C and C++ applications that use SQL................................................................ 15 Margins in C and C++ applications that use SQL............................................................................15 Names in C and C++ applications that use SQL.............................................................................16 NULLs and NULs in C and C++ applications that use SQL............................................................. 16 Statement labels in C and C++ applications that use SQL............................................................ 16 Preprocessor sequence for C and C++ applications that use SQL................................................ 16 Trigraphs in C and C++ applications that use SQL......................................................................... 16 WHENEVER statement in C and C++ applications that use SQL................................................... 17 Using host variables in C and C++ applications that use SQL.............................................................17 Declaring host variables in C and C++ applications that use SQL................................................. 18 Numeric host variables in C and C++ applications that use SQL............................................. 18 Character host variables in C and C++ applications that use SQL........................................... 18 Graphic host variables in C and C++ applications that use SQL.............................................. 21 Binary host variables in C and C++ applications that use SQL.................................................24 LOB host variables in C and C++ applications that use SQL.................................................... 25 XML host variables in C and C++ applications that use SQL.................................................... 28 ROWID host variables in C and C++ applications that use SQL............................................... 30 Result set locator host variables in C and C++ applications that use SQL.............................. 30 Using host structures in C and C++ applications that use SQL...........................................................31 Host structure declarations in C and C++ applications that use SQL............................................32 Host structure indicator array in C and C++ applications that use SQL........................................ 34 Using arrays of host structures in C and C++ applications that use SQL............................................34 Host structure array in C and C++ applications that use SQL........................................................36 Host structure array indicator structure in C and C++ applications that use SQL........................ 38 Using pointer data types in C and C++ applications that use SQL......................................................38 Using typedef in C and C++ applications that use SQL....................................................................... 39 Using ILE C compiler external file descriptions in C and C++ applications that use SQL.................. 40 iii Determining equivalent SQL and C or C++ data types........................................................................ 41 Notes on C and C++ variable declaration and usage..................................................................... 44 Using indicator variables in C and C++ applications that use SQL......................................................44 Coding SQL statements in COBOL applications........................................................................................ 45 Defining the SQL communication area in COBOL applications that use SQL..................................... 45 Defining SQL descriptor areas in COBOL applications that use SQL.................................................. 46 Embedding SQL statements in COBOL applications that use SQL..................................................... 48 Comments in COBOL applications that use SQL............................................................................48 Continuation for SQL statements in COBOL applications that use SQL........................................ 48 Including code in COBOL applications that use SQL..................................................................... 49 Margins in COBOL applications that use SQL.................................................................................49 Sequence numbers in COBOL applications that use SQL..............................................................49 Names in COBOL applications that use SQL.................................................................................. 49 COBOL compile-time options in COBOL applications that use SQL..............................................49 Statement labels in COBOL applications that use SQL..................................................................50 WHENEVER statement in COBOL applications that use SQL........................................................ 50 Multiple source COBOL programs and the SQL COBOL precompiler............................................ 50 Using host variables in COBOL applications that use SQL.................................................................. 50 Declaring host variables in COBOL applications that use SQL...................................................... 50 Numeric host variables in COBOL applications that use SQL.................................................. 50 Floating-point host variables in COBOL applications that use SQL......................................... 52 Character host variables in COBOL applications that use SQL................................................ 53 Graphic host variables in COBOL

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    212 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us