View previous topic :: View next topic
|
Author |
Message |
shchan
New User
Joined: 06 Jun 2007 Posts: 58 Location: Hyderabad
|
|
|
|
Hi,
I have to update transaction_details column in a DB2 table.
This column conatins hex values.I have to find the date part in this column and update it with another date.
Can anybody tell me how to achieve this. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
No.
The date should be in a separate field, preferable defined as a "date". . .
One of the biggest reasons to design a database is to eliminate exactly this sort of data.
If you simply try to find/identify a "hex" date somewhere in the 200 bytes, using program code, it will be quite difficult. As you've posted in the db2 part of the forum, i suspect you want to do this some kind of query. I also suspect this will not happen. . .
Possibly, i misunderstand? |
|
Back to top |
|
|
shchan
New User
Joined: 06 Jun 2007 Posts: 58 Location: Hyderabad
|
|
|
|
hello dick..thanks for the reply..
yes i want to write a DB2 query to update the date part.
Actually the transaction details column contains 3 different values year,days date and some other values.
I have to change the days to 0 and this is contained in 3rd byte of this column and 2 bytes of length ( that is 3rd byte of the transaction details column which is of 200 bytes) and there is a date part that starts from 8th byte and is 5 bytes of length which also needs an updation with another date that is being calculated in the query.
Can this be done in a query or do i need to write a DB2 program? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If it was my requirement to work with this 200-byte "thing", i would write code.
Also, if it was my requirement, i'd change the table definition, so there would be no 200-byte conglomeration. . . |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
You can not update a part of a column! Search this sort of dumb idea has been discussed before. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
You can not update a part of a column! |
Yup, not directly. . .
If this 200-byter was in WS and redefined as the multiple fields, the individual values could be modified as needed and the whole thing then updated back in the database.
My preference would surely to properly define the table/columns instead of working with this unmanagable mess. Try performing impact analysis on this |
|
Back to top |
|
|
wanderer
Active User
Joined: 05 Feb 2007 Posts: 199 Location: Sri Lanka
|
|
|
|
Db2 offers several functions like POSITION, HEX, SUBSTR using which you can tryout something. Not sure if possible. Look in SQL Reference manual.
But this idea seems silly to me. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
shchan wrote: |
Hi,
I have to update transaction_details column in a DB2 table.
This column conatins hex values.I have to find the date part in this column and update it with another date.
Can anybody tell me how to achieve this. |
I would speak directly with the idiot that designed this. |
|
Back to top |
|
|
|