Page 1 of 2

Changing format of column

PostPosted: Sun Jan 11, 2015 5:55 am
by vegafacundodaniel
Hi,
I need help please.

I have a DB2 table that has a index. That index has 3 columns. One of thoses columns is numeric and I need to transform it to character.

Current index:
ColumnA  CHAR(3    )
ColumnB  DECIMAL (2 , 0 )   ------------------> I need to change it
ColumnC  CHAR (2    )


New index:
ColumnA  CHAR(3    )
ColumnB  CHAR (2    )  ------------------> New format
ColumnC  CHAR (2    )


The documentation I have says to avoid to changing numeric ---> character because that causes many problems, but it doesn't say which ones....:(
Instead, it says to add 1 new colum at the end of the table but, that is not possible because the ColumnB is part of the key of the table.

Could anyone tell me what should I do ?
Thanks in advance!

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 5:42 pm
by prino
I can't say what you should do, but what you should have done is to think about your design before you started.

And changing data that is intrinsically numerical to character? PMAB!

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 6:10 pm
by vegafacundodaniel
I did not design that table.

It is strange to change numeric to character, but I need it. The values are numerics in the columnB.
The problem is my ERP that uses DB2 tables. When ColumnB est populated with spaces, it transforms automatically the spaces to zeros because ColumnB is defined as numerique. That causes a problem because I need to verify the ColumnB must be not empty.

It is for that I need to alter the ColumnB.

Thanks

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 8:15 pm
by prino
vegafacundodaniel wrote:The problem is my ERP that uses DB2 tables. When ColumnB est populated with spaces, it transforms automatically the spaces to zeros because ColumnB is defined as numerique. That causes a problem because I need to verify the ColumnB must be not empty

Ever heard of "NULL"?

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 8:40 pm
by vegafacundodaniel
WHen I want to check if columnB is empty (spaces) ou null (nothing), that column contains zeros, populated by the ERP. The ERP is a closed source that I can't not modify.
Thanks

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 9:19 pm
by enrico-sorichetti
that column contains zeros, populated by the ERP. The ERP is a closed source that I can't not modify.

how do You know that after changing the column the ERP application will still work ???

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 9:30 pm
by vegafacundodaniel
After changing the columnB, I need to adapte the customer procedures impacted (=programs).

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 10:01 pm
by enrico-sorichetti
The ERP is a closed source

just take a decision ...

the ERP/application/whateverYouwantto callthething

is it closed source or not ???

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 10:08 pm
by vegafacundodaniel
The ERP is a semi closed source. It makes somes things that I can't not control, for example, it makes zeros instead of spaces when a column is numeric.
Thanks

Re: Changing format of column

PostPosted: Sun Jan 11, 2015 11:01 pm
by vegafacundodaniel
Question please. If I:

- UNLOAD the old table (definition and data) with IKJEFT01 program. It makes 2 files (*)
- DROP old table (Tablespace, table, index..) with columnB as numeric
- CREATE new table with columnB as CHAR
- LOAD data with (*) using DSNUPROC program.
Question: the data from the old ColumnB (DECIMAL 2) populates the new columnB (CHAR 2) properly?

Thanks