Toad World® Forums

Data type script conversion


#1

Hi,

I have a universal data model and on conversion to SQL Server 2014, I want to convert all CHAR(1) data types to BIT. I have seen the scripting capability, so it seems possible (Data Type Conversion Settings dialog -> Go to Exception Script), but not quite sure where to start. If the length of the CHAR is anything greater than 1, then it should be left as is and not converted.

Thanks


#2

Hello Paul,

It should be possible to create such an Exception Script, if you give us a few days, we can hopefully create the script for you. For now, you might want to take a look at an example, which converts all Char attributes to Bit data type, so you can see how the script works:

function Convert(){

if (OutputModelDef.Abbrev=‘MS14’)
{ if ((InputDataType.ConversionID.Code) = ‘Chr’)
{
Result.DataType = OutputDataTypes.GetObjectByName(‘Bit’);
var index = 20;
return index;
}
}
}

Regards,

Lukas


#3

Thanks Lukas I will give it a try. Is the object model documented anywhere? From the look of your answer all I need to do is add an additional check to see if the CHAR length is 1. Do I also need to return a value if there is no conversion done?


#4

Hello again Paul,

Sorry for the delay, we’ve looked into this some more and unfortunately, it is not possible to access data type parameters in Conversion Script. Therefore, you cannot do conversions depending on parameter values.

I have created an enhancement request - TDM-1472 - to implement functionality which would allow you to access the parameters to do what you need. But it will be implemented in the next version of TDM at the soonest.

Regards,

Lukas