The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Using macro inside SQL queries

achint_kumarachint_kumar Member Posts: 16 Contributor II
edited April 2020 in Help
Hi All,

I am trying to use Macros very dynamically in the SQL queries used to retrieve data from DW. I am assigning macro values from Excel as input.  
I am facing some issues in doing so. It shows me error stating "eval is not a recognized built in function name"

Please find below screenshot of process:


Kindly help resolve this, is it that we cannot use these macros inside SQL functions?
Tagged:

Best Answers

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist
    Solution Accepted
    Hi,
    eval() can only be used in the expression parser. It should just work without.

    Best,
    Martin
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Solution Accepted
    Hi,

    a better way to do this is using the prepared statements option and specifying the parameters in the dialog. You can use the macros there and specify the data type. 
    This is a much safer way of putting macros (=strings) into SQL statements, you can avoid SQL injections and SQL syntax errors with the prepareds statements.

    Sometimes it's not possible to avoid using macros in SQL statements, but you should prefer the prepared statement method.
    An example when you can't use that is if structural aspects of the SQL query (table and column names) are variable and specified with a macro. E. g.:
    SELECT %{varColumn}
    FROM %{varTable}
    ORDER BY %{varSortOrder}
    Of course, you need to be extra careful when doing this, e. g. validate the format and contents of your macros before executing this.

    Best regards,
    Balázs
Sign In or Register to comment.