I'm having trouble declaring a variable in my query to use with Denodo.
I've tried writing it using sql syntax, but I get an error with "declare".
declare @var1 varchar(6) = 'table1'
select column_name, column_description
from view('pb', '@var1')
order by column_name
I expect this to run with the variable "var1" but I get error code 1100 with a message: "Syntax Error: Exception parsing query near declare".
You can use variables in Denodo with SETVAR('', '', '', ''). But this will only work with column names or conditions in where clauses. I have tested it and it does not work with view names.
Example:
select SETVAR('columnname','foo');
select GETVAR('columnname', 'text', 'asdf') from foobar
this returns the foo column of the foobar table
This does not work:
select SETVAR('tablename','foobar');
select * from GETVAR('tablename', 'text', 'asdf')
I don't think using a variable as table name is possible in denodo. You might need to do that in a script while writing the query.