Toad World® Forums

Attribute.DataType returns "undefined"

Hi,

I’m iterating over all Attributes of an entity (trying to write a Liquibase XML from within a JScript Macro). But for some reason the call to “Attribute.DataType” always returns “undefined”.

The function that I’m using looks like this:

function writeTable(Table)
{
Output.WriteLine(’’);
for (c=0; c < Table.Attributes.Count; c++)
{
Col = Table.Attributes.GetObject©;
if (Col.DataType != null)
{
dType = getLBType(Col);
Output.WriteLine(’’);
}
else
{
Log.Information(“Column " + Table.Name + “.” + Col.Name + " has no data type!”);
}
}
Output.WriteLine(’’);
}

The function getLBType() is simply a big if that maps TDM types to Liquibase types and does the replacement of the parameters. If I use Col.DataType in the WriteLine() call directly it simply writes “undefined” as well.

What am I missing here? In a different script the same call works without problems.

Do I need to “initialize” something before I can access the DataType property?

Silly me…

Of course it must be Col.DataType.Name

Yes, it must end with .Name or other property.
BTW: do not forget to declare variables in your scripts.
**var c, Col;
**Regards,

Vaclav

Message was edited by: vaclav