Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 9 Understanding the Transfer Process [Table of Contents] Chapter 11 Using Destination-Template Transfer

Access Service User's Guide DirectConnect Anywhere

[-] Chapter 10 Using Bulk Copy Transfer

Chapter 10

Using Bulk Copy Transfer

This chapter describes the bulk copy transfer process. It covers the following topics:

Overview

Bulk copy transfer initiates a direct transfer of data between two databases from the client application. You use the bulk copy transfer statement to copy large amounts of data between similar tables.

When you use a bulk copy transfer statement, the following restrictions apply:

Bulk Copy Transfer processing

Bulk copy transfer processing occurs in the following sequence:

Syntax

The required syntax for a bulk copy transfer statement is as follows:

transfer [with report]
{to | from} 'secondaryname  userid password';
with {insert | replace | truncate} into tablename;
sourceselectstatement

where:

Datatype conversion for transfer from statements

Use transfer from when you want to transfer data from a secondary database to the primary database. The primary database, ODBC, is the target. The secondary database is specified in the transfer statement.

The access service performs datatype conversions for bulk copy transfer from statements. These conversions are defined within the access service and are not affected by the settings of the datatype conversions configuration properties.

The following table shows the acceptable Open Server datatypes that the access service can convert into corresponding ODBC datatypes. To fit the items in the table, the CS_ prefix is removed from the datatypes, ODBC datatypes are shown in lowercase letters, and similar ODBC datatypes are combined.

Open Server to ODBC datatype conversions

Open Server Datatype

ODBC Datatypes

CHAR VARCHAR LONGVARCHAR

TINYINT SMALLINT, INT BIGINT, DECIMAL NUMERIC, REAL FLOAT, DOUBLE

DATE TIME TIMESTAMP

BINARY VARBINARY LONGVARBINARY

BIT

CHAR

X

X

X

X

X

TEXT

X

X

X

X

X

BINARY

X

X

VARBINARY

X

X

IMAGE

X

X

BIT

X

X

X

X

TINYINT

X

X

X

SMALLINT

X

X

INTEGER

X

X

MONEY

X

X

MONEY4

X

X

REAL

X

X

FLOAT

X

X

DATETIME

X

X

DATETIME4

X

X

Datatype conversion for transfer to statements

Use the transfer to statement when you want to move data to a secondary database from the primary database.

The access service performs datatype conversions for bulk copy transfer to statements. These conversions are defined within the access service and are not affected by the settings of the datatype conversions configuration properties.

Datatype conversion takes place in two steps. The following table shows how incoming target ODBC datatypes are initially converted to Open Server datatypes.

Initial ODBC to Open Server datatype conversion

ODBC Datatype

Open Server Datatype

SQL_CHAR

CS_CHAR

SQL_VARCHAR

CS_VARCHAR

SQL_LONGVARCHAR

CS_LONGCHAR

SQL_DECIMAL

CS_DECIMAL

SQL_NUMERIC

CS_NUMERIC

SQL_SMALLINT

CS_SMALLINT

SQL_INTEGER

CS_INT

SQL_REAL

CS_REAL

SQL_FLOAT

CS_FLOAT

SQL_DOUBLE

CS_FLOAT

SQL_BIT

CS_BIT

SQL_TINYINT

CS_TINYINT

SQL_BIGINT

CS_FLOAT

SQL_BINARY

CS_BINARY

SQL_VARBINARY

CS_VARBINARY

SQL_LONGVARBINARY

CS_LONGBINARY

SQL_DATE

CS_CHAR

SQL_TIME

CS_CHAR

SQL_TIMESTAMP

CS_CHAR

Table 10-3 shows how the converted datatypes from the previous table are converted into actual datatypes of the target columns. If a column match is incompatible, the transfer ends with an error.

To fit the items in the table, the CS_ prefix is removed from the datatypes, datatypes are shown in lowercase letters, and similar Open Server datatypes are combined.

Access service datatype to Open Server datatype conversion

Access Service Open Server Datatype

Target Open Server Column Datatypes

binary image

tinyint

smallint, int, float, real, money, money4, decimal

char

bit

datetime datetime4

text

binary

X

X

X

char

X

X

X

X

X

X

X

float

X

X

X

X

X

decimal

X

X

X

image

X

X

X

smallint

X

X

X

X

int

X

X

X

X

text

X

X

X

X

X

X

X

Processing Bulk Copy values

The following guidelines apply to bulk copy values.

Character datatypes

Character datatypes (CHAR, VARCHAR, TEXT) can be converted to any other datatype. Conversely, every datatype can be converted to character data. You must ensure that the character string is convertible to the target datatype.

For example, the character string "450" can be converted to a numeric datatype such as INTEGER or DECIMAL, but the character string "Hello" causes a value error going to a numeric datatype.

Numeric datatypes

Numeric datatypes can be converted to other numeric datatypes or to character datatypes, but they cannot be converted to binary or date datatypes.

Additional guidelines are as follows:

Date datatypes

Date datatypes can be converted to other date datatypes or to character strings. However, they cannot be converted to numeric or binary datatypes.

Binary datatypes

Binary datatypes can be converted to other binary datatypes or to character strings. However, these datatypes cannot be converted to numeric or other date datatypes.

Bulk Copy Transfer errors

Value errors occur during transfer processing when the value being inserted is out of range for the column datatype. The access service handles these errors using the following properties:

If the SendWarningMessages property is set to yes, the access service sends a message to the client application when it encounters value errors.

Bulk copy value processing rules

The following rules apply for values during the bulk copy transfer process:

Values that cause errors

The following table shows data values that can cause errors during transfer.

Values that cause errors

Open Server Input Datatypes

Open Server or ODBC Output Datatypes

Error Condition

char, varchar, text

OS char, varchar, text, binary, varbinary, or image. ODBC CHAR, VARCHAR, LONGVARCHAR

Source data is longer than the destination column.

char, varchar, text

OS decimal ODBC DECIMAL

Source is not a valid decimal string (must contain an optional leading sign and decimal digits). Number of digits to the left of the decimal point is greater than the destination column precision minus scale. Any digits to the right of the decimal will be lost without error.

char, varchar, text

OS integer ODBC INT

Source is not a valid decimal string (must contain an optional leading sign, decimal digits, decimal point, and fractional decimal digits). String of digits to the left of the decimal point is greater than 2147483647 (positive values) or less than -2147483648 (negative values). Any digits to the right of the decimal will be lost without error.

char, varchar, text

OS smallint ODBC SMALLINT

Source is not a valid decimal string (must contain an optional leading sign, decimal digits, decimal point, and fractional decimal digits). String of digits to the left of the decimal point is greater than 32767 (positive values) or less than -32768 (negative values).

char, varchar, text

OS tinyint ODBC TINYINT

Source is not a valid positive integer string (must contain an optional leading "+" and decimal digits). String of digits does not form an integer value between 0 and 255.

char, varchar, text

OS bit ODBC BIT

Source data length is greater than 1 or source value !="0" or "1."

char, varchar, text

OS float ODBC FLOAT

Source is not a valid floating point format string (must contain optional leading sign, decimal digits, optional decimal point, fractional decimal digits, and optional E[+|-] nnn exponent). Destination is ODBC and the value is out of range for an ODBC FLOAT.

char, varchar, text

OS real ODBC REAL

Source is not a valid floating point format string (must contain optional leading sign, decimal digits, optional decimal point, fractional decimal digits, and optional E[+|-] nnn exponent). Destination is ODBC and the value is out of range for an ODBC FLOAT. Destination is Adaptive Server and the value is greater than 3.402823466E38 or less than -3.402823466E38.

char, varchar, text

OS date ODBC DATE

Source is not an ISO format date (YYY-MM-DD) or a valid Adaptive Server date/time string with a year later than 1753.

char, varchar, text

OS time ODBC TIME

Source is not an ISO format time (HH.MM.SS) or an HH:MM:SS format time.

char, varchar, text

ODBC TIMESTAMP

Source is not an ISO format date (YYYY-MM-DD-HH.MM.SS) or a YYYY-MM-DD-HH.MM.SS.NNNNNN date with YYYY greater than 0001, or a valid Adaptive Server date/time string with a year later than 1753.

char, varchar, text

OS datetime

Source is not an ISO format date, time, or timestamp with a year later than 1752 or a valid Adaptive Server date/time string with a year later than 1752.

char, varchar, text

OS datetime4

Source is not an ISO format date, time, or timestamp with a year later than 1899 and the year, month, and day earlier than Jun 7, 2079, or a valid Adaptive Server date/time string with a year later than 1899 and the year, month, and day earlier than Jun 7, 2079.

char, varchar, text

OS money

Source is not a valid decimal string (must contain an optional leading sign, decimal digits, optional decimal point, and fractional decimal digits). Value is greater than 922337203685477.5807 or less than -922337203685477.5808.

char, varchar, text

OS money4

Source is not a valid decimal string (must contain an optional leading sign, decimal digits, optional decimal point, and fractional decimal digits). Value is greater than 214748.3647 or less than -214748.3648.

binary, varbinary, image

OS char, varchar, text, binary, varbinary, image ODBC CHAR, VARCHAR, LONGVARCHAR

Source data is longer than the destination column.

byte, int, smallint

OS char, varchar, text ODBC CHAR, VARCHAR

Destination column is too small to hold the digits required to express the value (for example, the source value is 103 and the destination column is char(2)).

byte, int, smallint

OS bit

Source value !=0 or 1.

smallint, int, float, real, money, money4, decimal

OS decimal ODBC DECIMAL

Destination column precision minus scale is too small to hold the value (for example, a source data value of 98 requires destination column precision minus scale of 2).

money, money4, decimal, numeric

OS decimal ODBC DECIMAL

If precision=scale=maximum, precision for the datatype does not transfer properly when the data value is 0. A workaround is to alter the table so that one of these conditions is avoided.

smallint

OS tinyint ODBC TINYINT

Source value is greater than 255 or less than 0.

int

OS smallint ODBC SMALLINT

Source is greater than 32767 or less than -32768.

int

OS money4

Source is greater than 214748 or less than -214748.

int

OS tinyint ODBC TINYINT

Source is greater than 255 or less than 0.

bit

OS decimal ODBC DECIMAL

Destination column precision minus scale is less than 1.

float, real

OS char, varchar, text ODBC CHAR, VARCHAR

Destination column is too small to hold the digits required to express the value (for example, source is 1030303E+30 and destination column is char(12)).

float, real, money

OS int ODBC INT

Source value greater than 2147483647.0 or less than -2147483648.0.

float, real, money, money4, decimal

OS smallint ODBC SMALLINT

Source is greater than 32767.0 or less than -32768.0.

float, real, money, money4, decimal

OS tinyint ODBC TINYINT

Source is greater than 255.0 or less than 0.0.

float, real

OS money

Source value is greater than 922337203685477.0 or less than -922337203685477.0. Since float accuracy is 15 digits, a value of this magnitude is accurate only to the nearest dollar. Since real accuracy is seven digits, a value of this magnitude is accurate only to the nearest hundred million dollars.

float, real, money, decimal

OS money4

Source is greater than 214748.3647 or less than -214748.3648.

float, real, money, money4, decimal

OS bit ODBC BIT

Source value !=0.0 or 1.1.

money, money4, decimal

OS char, varchar, text ODBC CHAR, VARCHAR, TEXT

Destination column is too small to hold digits required to express value (for example, source is 100000000.001 and destination column is char(12)).

datetime, datetime4

OS char, varchar, text ODBC CHAR, VARCHAR, LONGVARCHAR

Destination column length is less than 19.

datetime

OS datetime4

Date portion of source value is earlier than Jan 1 1900 or later than Jun 6 2079.

Bulk copy Transfer error reporting

You can obtain bulk copy transfer error information in the following ways:


Chapter 9 Understanding the Transfer Process [Table of Contents] Chapter 11 Using Destination-Template Transfer