Toad World® Forums

How to check attribute for NotNull and getting data type as text?

Hi I tried to check an attribute for NotNull and want to get the DataType as text.

So I used this code:
--- SNIP ---
for(i=0; i<Model.Entities.Count;i++) {
// Current Entity
Entity = Model.Entities.GetObject(i);

    // Check every attribute
    for(j=0; j<Entity.Attributes.Count;j++) {
        Attribute = Entity.Attributes.GetObject(j);
        Log.Information(Attribute.NotNull); // <--- Fails
        Log.Information(Attribute.GetDataTypeAsText()); // <---Fails, too

--- SNAP ---

According the documentation, the Property NotNull is available:
--- SNIP ---
NotNull boolean
Store property
TDM3 Application
--- SNAP ---

There are an function named GetDataTypeAsText, too:
--- SNIP ---
GetDataTypeAsText Generator: dispatch
widestring TDM3 Application
--- SNAP ---

Any idea, why it fails (see also attachment)?

Thanks a lot!

Attribute class (PERAttribute) has property: IsNotNull (not NotNull as you have used)
Check reference manual available in TDM’s Help menu

For column type use Attribute.DataType.Caption - taken from Toad Data Modeler help

In response to:
*Berthold’s original issue:
Log.Information(Attribute.GetDataTypeAsText()); // <—Fails, too
— SNAP —
*It was driving me nuts as the help does not really help. Looking at code within the package explorer also is not helpful - as most scripts refer to and use the keyword Instance – which does not seem to be available in the macros I was writing. After trying several ways to pass the parameter for the above function, I passed null and viola – it worked. Cannot explain why, but it worked

Hope this helps!


  1. NotNull: Log.Information accepts only strings. That means that if you wish to add boolean or integer values than you must use .toString() javascript method.


  1. Datatype as text: In reference guide you can find info about required parameters. In this case Generator should be passed as parameter.

var Generator = Attribute.Root().DefaultCodeGenerator;

Log.Information(Attribute.GetDataTypeAsText(Generator ));


Vaclav & Mario


find below some useful information:

The final answer is very useful and extremely not obvious. Since scripting is a strength of TDM, I think this sort of commonly needed information (attribute type as a string) should be prominently presented both in the help Reference Guide, and also an expanded scripting guide with more examples.

Thanks for your feedback. We will work on documentation improvements.