Consultor Eletrônico



Kbase P125969: How to change the datatype of a database field ?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/12/2010
Status: Unverified

GOAL:

How to change the datatype of a database field ?

GOAL:

Is there any utility or tool to change the datatype of a database field?

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
All Supported Operating Systems

FIX:

If the database is empty and/or you do not mind loosing all data in
the specific field. You can just delete the field you want to change
and create a new one with the same preferences except DATA TYPE.
If you do mind loosing data follow the steps below:
---------------------------------------------------
- run Progress with connected database
- run:
output to filename.d.
for each table-name: export recid(table-name) table-name.field-name.
end.
output close.
- this dumps the content of the field
- delete the field and create a new one with the same preferences
except DATA TYPE - NOTE: ALL DATA IS LOST FROM THE FIELD !!!
- run:
input from filename.d.
define variable temp as original-data-type no-undo.
define variable rectmp as recid no-undo.
repeat:
import rectmp temp.
find first table-name where recid(table-name) = input(rectmp).
assign table-name.field-name = conversion-function(temp).
release table-name.
find next table-name exclusive-lock.
end.
input close.
- this loads the data back into the database
CONVERSION-FUNCTION is any function which converts between any data
types: STRING, DECIMAL, INTEGER, DATE, etc.