You can translate the question and the replies:

How to use declare & set in Denodo?

I need to rewrite one SQL Management Studio query into Denodo. Which Im using declare & set. This is me query: declare @datefrom as varchar(12); set @datefrom='2023-07-01'; declare @dateto as varchar(12); set @dateto='2023-07-31'; declare @entity as varchar(6); set @entity='T007' . . . (SELECT DISTINCT P.ADID FROM table1 P WHERE P.CREATEDDATETIME BETWEEN @datefrom AND @dateto AND P.ID>0 AND P.DATAID=@entity) Error in Denodo: Command #1 Statement: declare @datefrom as varchar(12) Syntax error: Exception parsing query near 'declare' Command #2 Statement: set @datefrom='2023-07-01' Syntax error: Exception parsing query near '@' Command #3 Statement: declare @dateto as varchar(12) Syntax error: Exception parsing query near 'declare' Command #4 Statement: set @dateto='2023-07-31' Syntax error: Exception parsing query near '@' Command #5 Statement: declare @entity as varchar(6) Syntax error: Exception parsing query near 'declare' Command #6 Statement: set @entity='T007' Syntax error: Exception parsing query near '@' Is there any solution/alternative for this problem? Thank you in advance.
user
15-02-2024 05:03:06 -0500
code

1 Answer

Hi, Virtual Dataport has a procedural language to create stored procedures that would invoke VQL statements and allows us to use elements such as conditions and loops. If I need to **declare a variable and assign value** to that variable using VQL stored procedures, then I would use the below commands . ``` Variable_name <datatype>; Variable_name:= <value_of_variable>; ``` The syntax for creating a simple VQL procedure is given below: ``` CREATE OR REPLACE VQL PROCEDURE <name_of_the_procedure> (<variable_name> <Type_of_variable> <data_type>) AS ( local_variable <data_type>; ) BEGIN <Command1> <Command2> END ``` For further information about developing VQL procedures, please refer to the [Developing VQL Stored Procedures](https://community.denodo.com/docs/html/browse/8.0/en/vdp/developer/developing_extensions/developing_stored_procedures/developing_vql_stored_procedures) section under the Virtual DataPort Developer Guide . Hope this helps!
Denodo Team
19-02-2024 01:27:20 -0500
code
You must sign in to add an answer. If you do not have an account, you can register here