View previous topic :: View next topic
|
Author |
Message |
Satyajit
New User
Joined: 25 Jan 2006 Posts: 27
|
|
|
|
can i define the layout of the attribute inside a row?
ie MERCHANT_ADDRESS in the table below consists of the following fields.
How should i craeate the table? can i specify it in MERCHANT_ADDRESS field.
MERCHANT TABLE DETAILS
MERCHANT_ID CHAR(5) PRIMARY KEY
MERCHANT_NAME CHAR(10)
MERCHANT_ADDRESS CHAR(40)
(MERCHANT_ADDRESS CONSISTS OF
MERCHANT_STREET CHAR(15)
MERCHANT_CITY CHAR(10)
MERCHANT_STATE CHAR(10)
MERCHANT_ZIP CHAR(5) ) |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
You cannot redefine a column like that. Why would you not want to either define the table as :
MERCHANT_ID CHAR(5) PRIMARY KEY
MERCHANT_NAME CHAR(10)
MERCHANT_ADDRESS CHAR(40)
or
MERCHANT_ID CHAR(5) PRIMARY KEY
MERCHANT_NAME CHAR(10)
MERCHANT_STREET CHAR(15)
MERCHANT_CITY CHAR(10)
MERCHANT_STATE CHAR(10)
MERCHANT_ZIP CHAR(5)
I think the second definition is probably better. If you need to select th 40 byte MERCHANT_ADDRESS you can do:
Code: |
SELECT MERCHANT_STREET ||
MERCHANT_CITY ||
MERCHANT_STATE ||
MERCHANT_ZIP
INTO :WS-MERCHANT-ADDRESS
|
Dave |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
That's another reason to like ADABAS: it lets you create a "group" field that may include other fields...
O. |
|
Back to top |
|
|
Satyajit
New User
Joined: 25 Jan 2006 Posts: 27
|
|
|
|
Can I retieve or insert data into the column in that order? |
|
Back to top |
|
|
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
Hi,
There are two ways to do that.
1. you create the table with all three different attributes.
2. You can create a type MERCHENT_ADDRESS which has all three attributes. then you can have an attribute of type MERCHENT_ADDRESS
As far as I know, its possible in DB2 to create type. Not really sure. You should consult manuals. |
|
Back to top |
|
|
|