473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DB2 Load Varchar for bit data

How do I load "varchar for bit" data in hexadecimal format into a DB2
table ?

Table definition
===========
create table test
( i integer, v varchar for bit data (16))

db2 "IMPORT FROM "data.txt" OF DEL MODIFIED BY COLDEL, METHOD P (1, 2)
MESSAGES "/tmp/db2-load-error.log" INSERT INTO test (i,v)";

data.txt file contents
=============
,F66A7FCB526C98B61E73BD966C85C1FA
,F66A7FCB526C98B61E73BD966C85C1FA

Error message

SQL3125W The character data in row "1" and column "2" was truncated
because
the data is longer than the target database column.

May 18 '06 #1
2 9867
I don't think there's any way to do this.

Import (and load), when using DEL, expect character data for the second
column. The character column data can be specified with or without
quotes but there is no way, as far as I know, to tell the utilities that
the data is formatted as (human) readable hex data and must be converted
back to internal format.

If you are creating this output from another source, you have two
options available.

1. Don't convert the data to readable hexadecimal. You should surround
the data with generated quotes (") and will need to double up any hex
character in the data that is a quote to avoid early termination of the
field. If you don't use the quotes, then you cannot have a comma (,)
character in the data. The hex equivalents of these characters are
dependent on your underlying hardware.

2. Do not use import. Create your data records as:
insert into test values(N,x'S.........S');
where N is the numeric and S......S is the hex string. This file can be
run, after connecting to the database, with:
db2 -tf data.txt
If an application is generating the data, you can also place commit
statements in the file at appropriate intervals.
Phil Sherman

im*****@gmail.com wrote:
How do I load "varchar for bit" data in hexadecimal format into a DB2
table ?

Table definition
===========
create table test
( i integer, v varchar for bit data (16))

db2 "IMPORT FROM "data.txt" OF DEL MODIFIED BY COLDEL, METHOD P (1, 2)
MESSAGES "/tmp/db2-load-error.log" INSERT INTO test (i,v)";

data.txt file contents
=============
,F66A7FCB526C98B61E73BD966C85C1FA
,F66A7FCB526C98B61E73BD966C85C1FA

Error message

SQL3125W The character data in row "1" and column "2" was truncated
because
the data is longer than the target database column.

May 19 '06 #2
You can create an udf to read the data file. Convert 2nd column to
hexadecimal in the function. Then insert the function's result into
your table.

Please refer to below link.

http://www-128.ibm.com/developerwork...303stolze.html

db2 "INSERT INTO test_table VALUES ( readFile( '/home/stolze/test_file'
) )"

credits to Knut.

Regards,

Mehmet Baserdem

May 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Uthuras | last post by:
Greetings all, Machine : PENTIUM Os :Windows 2000 Product : DB2 UDB EE Release : 7.2 I've extracted data from a RDBMS database and try to load into DB2 database. I extracted the...
1
by: Uthuras | last post by:
Greetings, Machine : Pentium IV Os Windows 2000 server Product : DB2 UDB Release : 7.2 We are fail to load the following data file format into db2 database table that has long varchar...
3
by: roy_ware | last post by:
I'm using a VB.Net interface to load an Access table. The relationship is 1 input record to many table rows. The problem is that the first name of the first row is populated for every row on the...
4
by: CPD | last post by:
From PHP, doing a DROP TABLE and a CREATE TABLE is successful, but doing a LOAD FILE keeps failing, with the error "Access denied for user 'db_user'@'localhost' (using password: YES)". The...
7
by: tojigneshshah | last post by:
Hi, I am loading data from ascii delimiter file and some of the rows are getting rejected while loading. 1.0|11487.0|FQ|105061.0|332735.0|01|X.NNIE HATFIELD|1992-06-25 00:00:00|1992-...
3
by: Mark S | last post by:
Hello, I'm attempting to use LOAD as an on-the-job training task. It's my first work with DB2, but I've worked with MySQL, so I didn't expect it to be too different. I have found some clues...
2
by: Steve Rainbird | last post by:
Is there way of telling the load utility that if it finds spaces in the input file, where it expects an integer, to insert a zero? Currently I am getting an error. SQL3116W The field value in...
13
by: rdudejr | last post by:
Hi all, I hardly ever make a post unless I am having a very purplexing issue, so this one should be good... I am trying to do a load against a database on an AIX server into a DB2 v9.1...
1
by: SnakesRule | last post by:
I'm trying to pull data from remote xml files to load the database of a library. My sources are www.amazon.com and www.ISBNdb.com. But when I try to search and read the xml files, I get this error: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.