
Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Hi Serge,
I am little confused so let me display the entire scenario one more
time.
Here's real scenario.
I have table called 'validation' in one database. And the columns are
as follows:
receipt_id char(11) not null,
receipt_seq integer not null,
payee_num char(5),
payment_amt decimal(16),
email_addr varchar(35),
payee_addr1 varchar(35),
payee_addr2 varchar(35),
payee_addr3 varchar(30)
The table validation already has data and it looks something like this:
receipt_id receipt_seq payee_num
------------- --------------- -------------
001100AB 1 12341
001100AB 1 23232
001100AB 1 65432
001100BA 1 23424
001100BA 1 64352
001100BB 1 23627
001100BB 1 90201
002130CC 1 89292
002530DA 1 67782
Now, i wanted to load the data from table validation into a new table
called validation_new with new column (receipt_num) in the new table
but in another database.
The new column (receipt_num) in a new table (validation_new) will look
like this:
receipt_id char(11) not null,
receipt_seq integer not null,
receipt_num integer not null,
payee_num char(5),
payment_amt decimal(16),
email_addr varchar(35),
payee_addr1 varchar(35),
payee_addr2 varchar(35),
payee_addr3 varchar(30)
And the record should look something like this:
receipt_id receipt_seq receipt_num payee_num
------------- --------------- --------------- -------------
001100AB 1 1 12341
001100AB 1 2 23232
001100AB 1 3 65432
001100BA 1 1 23424
001100BA 1 2 64352
001100BB 1 1 23627
001100BB 1 2 90201
002130CC 1 1 89292
002530DA 1 1 67782
So, how to load the data from the flat file with new receipt_num?
Any help would be of greatly appreciated.
Thanks
Jignesh
> > Serge,
> >
[quoted text clipped - 53 lines]
> Cheers
> Serge
Serge Rielau - 24 Apr 2006 20:21 GMT
Simply import into the new table and set the column to a default value.
Then run the UPDATE statement I provided to populate the column.
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
tojigneshshah@gmail.com - 24 Apr 2006 22:14 GMT
Hi Serge,
Appreciate all your kind replies. It looks simple, but still i m facing
some problem while importing data.
>From the previous mail, I have created a new column with 'default 0'.
While i import from flat file (of del), the first row is getting
inserted, while other records are rejected by violating primary key
constraints and getting SQL0803N.
Any idea wat is causing this?
thanks
Jignesh
> Simply import into the new table and set the column to a default value.
> Then run the UPDATE statement I provided to populate the column.
>
> Cheers
> Serge
Serge Rielau - 25 Apr 2006 01:18 GMT
> Hi Serge,
>
[quoted text clipped - 7 lines]
>
> Any idea wat is causing this?
I assume your new PK includes teh new column?
Of course that won't work until teh update is doen.
So, leave the PK away, import, update, then ALTER TABLE ADD PRIMARY KEY.
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
tojigneshshah@gmail.com - 26 Apr 2006 22:58 GMT
altast, it work the way i want.
Here's what i did.
1.Created a temp table.
2.loaded the data into the temp table.
3. exported the data from the temp table with rownumber () over ...
4. created new table with the new table. (without the PK)
5. loaded the data into the new table with the selected column (leaving
all not null columns)
6. updated the new column (receipt_num) with the update with partition
by and order by.
7. created pk.
Thanks for your help.
Regards
Jignesh