Search code examples
wso2siddhiwso2-daswso2-cep

Can we use variables in Siddhi SQL statements?


I'm going to use the same value in lots of statements in the SQL Expression. So it is possible to declare and assign the value to a variable at the beginning of the query and refer the value by it? (I'm writing an execution plan in WSO2 DAS)


Solution

  • This is not supported as of now. However, supporting this has been under discussion, hence this might be implemented in a future release.

    If you want to store a value and use it in a query, the currently available ways are:

    • Putting that value into an indexed event table and then doing a join with the event table to read that value whenever required.

    Indexed In-memory Event Table internally uses a Hash-Map, therefore you could use one to store your variables, in such a way that the key of the hashmap will be the name of your varaible and the value of the hashmap will be the value of your variable.

    However I feel that above solution is too complicated for your requirement.