View previous topic :: View next topic
|
Author |
Message |
kovur
New User
Joined: 15 Nov 2007 Posts: 36 Location: India
|
|
|
|
Hi,
I have a code which reads the input file and inserts the record into a table.
Now, I have a field called SCHEME in the file which is of length 20 defined as ALPHANUMERIC.
Now, I need to move this field into the table field which is of length 3 defined as CHAR.
The field SCHEME from the file may contain one word, two words and so on.
Now, the problem is how to move this 20 byte field to a 3 byte field?
We are thinking of moving the first three bytes of the file field but we are getting duplicates which the table will not accept, the table field being a part of the index.
We are also thinking to use the first three bytes if it has one word and use the first byte of each word if the field has more than one word.
But still we are getting duplicate values for the field in this case also.
All this should be done in the code it self.
Please let me know what other ways we can think of. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Poor design/implementation... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
Now, the problem is how to move this 20 byte field to a 3 byte field? |
if it were possible it would be the nightmare of storage marketing people |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Please clarify Your needs...
there is no way to squeeze into three bytes the info contained in twenty bytes
( unless Shannon had it completely wrong...
if You are interested search for "shannon entropy" ) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Now, the problem is how to move this 20 byte field to a 3 byte field? |
Sorry, but that is not just a problem - it is not do-able. . .
One alternative is to re-define the table to accomodate the full width of the data.
As was requested before, please clarify excatly what you need to do. Your post does not explain the requirement, but rather a "solution" that does not work. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Well if there was only 999 posible combinations, a table lookup/translate might work....
Or 99999 iif packed decimal....
Or 16777215 if binary....... |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
With a 3 byte alphanumeric code you could handle a lot of combinations, it just depends on how may variations there are in that 20 byte field. Sounds like a slight design problem. |
|
Back to top |
|
|
kovur
New User
Joined: 15 Nov 2007 Posts: 36 Location: India
|
|
|
|
Hi friends,
Thanks for your response.
I did not expect that the following line can make people confused.
kovur wrote: |
Now, the problem is how to move this 20 byte field to a 3 byte field? |
In fact, the problem is we have to take 3 bytes from the 20 byte field and move it to the table field which is char(3)
Which 3 bytes to take is the problem.
One more issue is there is a possibility that we may get a new SCHEME name in future. Then, 3 bytes should be taken from that filed and moved to the table.
Please let me know if everything is clear by now or any thing else is needed. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
the real question ( not answered yet )
what is the projected usage of these three bytes
given that the mapping of 20 to 3 will never be unique
( unless, as many posters do, You are hiding/not-telling something ) |
|
Back to top |
|
|
kovur
New User
Joined: 15 Nov 2007 Posts: 36 Location: India
|
|
|
|
Hi Enrico,
This three byte field will be moved to the table DCLGEN and this along with other fields is used to Update or insert the record in to the table.
Hope I gave the correct answer. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
You just told that You are shuffling things around
but not the logic why the application wants to squeeze 20 bytes in 3 bytes |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If you explain the business requirement or rule you need to implement (rather than talking about 20 or 3 bytes), we may be able to offer better suggestions.
So far, most of us do not understand what you need to do. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Kovur,
You might try something like this to get your problem across:
Quote: |
I have a 20 byte field that looks like this:
(Show the field here)
The 3 bytes I want to move are:
(Show the 3 bytes here)
The position of the 3 bytes will vary from rec to rec; the position in the 20 byte variable might change too, etc., etc. |
I'm only guessing at what you may include, but you get the idea. |
|
Back to top |
|
|
|