Toad World® Forums

Option to change datatype from Char(n) to VarChar2(n) when generating DDL

Hi,

Is there an existing Enhancement Request for this issue?

Option to change datatype from Char(n) to VarChar2(n) when generating DDL Script.

eg.

–THIS IS WHAT I GET:

CREATE TABLE race_meet_pools_f(
race_type_id Char(2 BYTE),
DATE_ID Integer,
provider_id Char(3 BYTE),
course_locn_id Integer,
DD Number(15,2),
QD Number(15,2),
TT Number(15,2),

–THIS IS WHAT I WANT:

CREATE TABLE race_meet_pools_f(
race_type_id VarChar2(2),
DATE_ID Integer,
provider_id VarChar2(3),
course_locn_id Integer,
DD Number(15,2),
QD Number(15,2),
TT Number(15,2),

Regards,
Yew Wee

Hello Yew,

Please find attached a script that will go through all attributes and change every Char data type (without specification if the length is in BYTE or CHAR) to Varchar2.
Example: Char(20 BYTE) will be changed to Varchar2(20).
The script works for all supported Oracle versions.

Please execute the script in Scripting Window (Tools menu, Expert mode has to be on - Settings | Options | General | Expert Mode checkbox).

If you have any questions, please write us back. Thanks.

Regards,

Vladka + TDM Team
DatatypeChange.js (1.08 KB)

Not a jscript scriptor. Code does not seem to work for version 4. I think I have the correct app object number?

I was trying to create an automation script where varchar < 255 set it to 255. Where greater than 255 then set to max.

Also trying to change all numerics to (38,2) unless there is a scale of 0 then I just want to convert them to an integer

Hi,

the script works in version 4.x
Please make sure you work with the right model. The following article explains how to use scripting window:

http://blogs.inside.quest.com/modeling/2012/01/04/scripting-window-tdm/

Information about objects and properties can be found in Reference, incl. information about data types.

Regards,

Vaclav