IBM Books

What's New


SQL Enhancements

BIGINT Data Type

The BIGINT data type is a newly supported SQL data type that allows applications to define BIGINT host variables and retrieve data into 64-bit integer types when this is supported by the programming language.

The sections below show the mapping between the BIGINT data type and C and C++, COBOL, and Java.

BIGINT Data Type in C and C++

The following table shows the C/C++ equivalent column type for the new BIGINT data type. When the precompiler finds a host variable declaration, it determines the appropriate SQL type value. The database manager uses this value to convert the data exchanged between the application and itself.

Table 6. BIGINT Data Type Mapped to C/C++ Declarations
SQL Column Type1 C/C++ Data Type2 SQL Column Type Description
BIGINT
(492 or 493)

long long
long long int
__int64

64-bit signed integer
Notes:
  1. The first number under Column Type indicates that an indicator variable is not provided, and the second number indicates that an indicator variable is provided. An indicator variable is needed to indicate NULL values, or to hold the length of a truncated string. These are the values that would appear in the SQLTYPE field of the SQLDA for these data types.
  2. Windows operating systems use __int64, where __ represents 2 underscores.

BIGINT Data Type in COBOL

The table below shows the COBOL equivalent of each column type. When the precompiler finds a host variable declaration, it determines the appropriate SQL type value. The database manager uses this value to convert the data exchanged between the application and itself.

Table 7. BIGINT Data Type Mapped to COBOL Declarations
SQL Column Type1 COBOL Data Type SQL Column Type Description
BIGINT
(492 or 493)

01 name PIC S9(18) COMP-5. 64-bit signed integer
Notes:
  1. The first number under Column Type indicates that an indicator variable is not provided, and the second number indicates that an indicator variable is provided. An indicator variable is needed to indicate NULL values, or to hold the length of a truncated string. These are the values that would appear in the SQLTYPE field of the SQLDA for these data types.

BIGINT Data Type in Java

When you call UDFs and stored procedures that are implemented as Java methods, DB2 converts SQL types to and from Java types for you. The table below shows how BIGINT is converted.


Table 8. BIGINT Data Type and Java Objects
SQL Type Java Type (UDF) Java Type (Stored Procedure)
BIGINT (492 or 493) long long

Fetch-first-clause

Use the FETCH FIRST clause with the SELECT statement to set a maximum number of rows that can be retrieved. It lets the database manager know that the application does not want to retrieve more than a specific number of rows, regardless of how many rows there might be in the result table when this clause is specified.

For more detailed information on how to specify the FETCH FIRST clause and the SELECT statement, refer to the SQL Reference.

Altering Tables

When a table is created, the default for append mode is OFF, meaning when the table has data inserted, the data is placed where free space is available in data pages.

If you want new table data appended to the end of the last table page, change the append option on the ALTER TABLE statement to ON.

Recognizing Equivalence of Repeated Host Variables

Users are strongly advised not to change the SQLDA after binding a DB2 embedded SQL program. If there are two or more occurences of a host variable in an SQL statement, the SQLDA will have duplicate entries for the variable, but only the first instance of the variable will be used by DB2. If a variable reference is change to a different variable, it will have no affect on the program. In general, users are advised not to change the output from the precompiler.


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

[ DB2 List of Books | Search the DB2 Books ]