Application Building Guide


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 and Stored Procedures
  • Microsoft Visual C++
  • ActiveX Data Objects (ADO)
  • Object Linking and Embedding (OLE) Automation
  • OLE Automation UDFs and Stored Procedures
  • DB2 CLI Applications
  • Building and Running Embedded SQL Applications
  • DB2 CLI Applications with DB2 APIs
  • DB2 CLI Stored Procedures
  • DB2 API and Embedded SQL Applications
  • Building and Running Embedded SQL Applications
  • Embedded SQL Stored Procedures
  • User-Defined Functions (UDFs)
  • IBM VisualAge C++ Version 3.5
  • DB2 CLI Applications
  • Building and Running Embedded SQL Applications
  • DB2 CLI Applications with DB2 APIs
  • DB2 CLI Stored Procedures
  • DB2 API and Embedded SQL Applications
  • Building and Running Embedded SQL Applications
  • Embedded SQL Stored Procedures
  • User-Defined Functions (UDFs)
  • IBM VisualAge C++ Version 4.0
  • IBM VisualAge COBOL
  • Using the Compiler
  • DB2 API and Embedded SQL Applications
  • Building and Running Embedded SQL Applications
  • Embedded SQL Stored Procedures
  • Micro Focus COBOL
  • Using the Compiler
  • DB2 API and Embedded SQL Applications
  • Building and Running 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.ibm.com/software/data/db2/udb/ad
     
    

    Notes:

    1. All applications on Windows 32-bit operating systems, both embedded SQL and non-embedded SQL, must be built in a DB2 command window, and not from an operating system command prompt.

    2. Any path names used in your programs that include the variable %DB2PATH% should be enclosed in quotes, as in: "%DB2PATH%\function", as the default installation for DB2 on Windows 32-bit operating systems for Version 7.1 is \Program Files\sqllib, which contains a space. If quotes are not used, you may get an error such as: "the syntax of the command is incorrect". In this chapter, such a path name is only enclosed in quotes if given as part of a command or code example.

    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 ]