Custom macro in SchemaModeler

Hi

for inject custom SQL I am trying to use custom macros.

I need to define custom fields which at run-time can refer to tables on different schemes. Now if I define only one macro the SchemaModeler validates it correctly while if I define 2 or more macros the validation fails.

With one macro field:

With two macro fields:

Is it possible to define more custom macros or is there a limit?

Thank you very much

Hi,

Can you send your schema to support@, pls?
I’d like to see how to your macros are declared

Hi EvgenyK

Sure! I can send it here because is a demo.

Schema.7z (4.1 KB)

Thank you very much

Hello

There are no limits however there are 3 things you should be aware of:

  1. Custom macros are calculated at runtime. So it is not possible for Schema Modeler to properly verify statements containing custom macros or to create field definitions from the statement results. DASM cannot set correct macro values so it just uses macro name as a default value.
  2. Custom macros are not secure. You should not allow to set their values from client side. Otherwise it would be an open SQL Injection vulnerability
  3. By default custom macros are disabled on the DataService level. You’ll need to set corresponding service property to enable them.

Regards

Hi AntonK

Ok. But why if I insert a custom macro the Schema Modeler validates the statment correctly while if I insert 2 it doesn’t? Conceptually either it always validates it or it never validates it.

Yes, I know. I use it only server side and based on the name of the macro I have already defined the SQL statment to replace. Nothing is built at run-time

Yes. I enabled it :wink:

Thank you very much

It is just a coincidence. When only 1 macro is used the resulting SQL statement is formally correct.

1 Like