IBM Books

Application Building Guide


Chapter 11. Building Applications for Windows 32-bit Operating Systems

  • Microsoft Visual Basic
  • ActiveX Data Objects (ADO)
  • Remote Data Objects (RDO)
  • Object Linking and Embedding (OLE) Automation
  • OLE Automation UDFs
  • OLE Automation Controller for Stored Procedures
  • Microsoft Visual C++
  • ActiveX Data Objects (ADO)
  • Object Linking and Embedding (OLE) Automation
  • OLE Automation UDFs
  • OLE Automation Controller for Stored Procedures
  • DB2 API Applications
  • DB2 CLI Applications
  • DB2 CLI Stored Procedures
  • Embedded SQL Applications
  • Embedded SQL Stored Procedures
  • User-Defined Functions (UDFs)
  • IBM VisualAge C++ Version 3.5
  • DB2 API Applications
  • DB2 CLI Applications
  • DB2 CLI Stored Procedures
  • Embedded SQL Applications
  • Embedded SQL Stored Procedures
  • User-Defined Functions (UDFs)
  • IBM VisualAge C++ Version 4.0
  • DB2 API Applications
  • DB2 CLI Applications
  • DB2 CLI Stored Procedures
  • Embedded SQL Applications
  • Embedded SQL Stored Procedures
  • User-Defined Functions (UDFs)
  • IBM VisualAge COBOL
  • Using the Compiler
  • DB2 API Applications
  • Embedded SQL Applications
  • Embedded SQL Stored Procedures
  • Micro Focus COBOL
  • Using the Compiler
  • DB2 API Applications
  • Embedded SQL Applications
  • Embedded SQL Stored Procedures
  • Object REXX
  • This chapter provides detailed information for building applications on Windows 32-bit operating systems. In the batch files, commands that begin with db2 are Command Line Processor (CLP) commands. Refer to the Command Reference if you need more information about DB2 commands.

    For the latest DB2 application development updates for Windows 32-bit operating systems, visit the Web page at:

      
    
    http://www.software.ibm.com/data/db2/udb/ad
     
    
    Note:All applications on Windows 32-bit applications, both embedded SQL and non-embedded SQL, must be built in a DB2 command window, and not from an operating system command prompt.

    WCHARTYPE CONVERT Precompile Option

    The WCHARTYPE precompile option handles graphic data in either multi-byte format or wide-character format using the wchar_t data type. More information on this option can be found in the Application Development Guide.

    For DB2 for Windows 32-bit operating systems, the WCHARTYPE CONVERT option is supported for applications compiled with the Microsoft Visual C++ compiler. However, do not use the CONVERT option with this compiler if your application inserts data into a DB2 database in a code page that is different from the database code page. DB2 normally performs a code page conversion in this situation; however, the Microsoft C run-time environment does not handle substitution characters for certain double byte characters. This could result in run time conversion errors.

    The WCHARTYPE CONVERT option is not supported for applications compiled with the IBM VisualAge C++ compiler. For this compiler, use the default NOCONVERT option for WCHARTYPE. With the NOCONVERT option, no implicit character conversion occurs between application and the database manager. Data in a graphic host variable is sent to and received from the database manager as unaltered Double Byte Character Set (DBCS) characters.

    If you need to convert your graphic data to multi-byte format from wide-character format, use the wcstombs() function. For example:

        wchar_t widechar[200];
        wchar_t mb[200];
        wcstombs((char *)mb,widechar,200);
     
        EXEC SQL INSERT INTO TABLENAME VALUES(:mb);
    

    Similarly, you can use the mbstowcs() function to convert from multi-byte to wide-character format.

    Do not issue a setlocale() call from your application if your application is statically bound to the C run-time libraries, as this may lead to C run-time conversion errors. Using setlocale() is not a problem if your application is dynamically bound to the C run-time library. This is also the case for stored procedures.

    Object Linking and Embedding Database (OLE DB) Table Functions

    DB2 supports OLE DB table functions. For these functions, there is no application building needed besides creating the CREATE FUNCTION DDL. OLE DB table function sample files are provided by DB2 in the %DB2PATH%\samples\oledb directory. These are Command Line Processor (CLP) files. They can be built with the following steps:

    1. db2 connect to database_name

    2. db2 -t -v -f file_name.db2

    3. db2 terminate

    where database_name is the database you are connecting to, and file_name is the name of the CLP file, with extension .db2.

    For a full description of OLE DB table functions, see the Application Development Guide.


    [ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

    [ DB2 List of Books | Search the DB2 Books ]