You can translate the question and the replies:

how to create temporary tables in VQL Stored procedures

Hi Denodo team, Could you please help me on creating temporary tables in VQL stored procedures with example if possible. **I am trying the save the below code but getting error saying** ***Error saving stored procedure: Syntax error: Exception parsing query near 'CREATE*'** (Program_Code IN VARCHAR,Source_Date_From IN DATE,Source_Date_To IN DATE) AS ( // Procedure variables ProgramCode VARCHAR;SourceDateFrom DATE;SourceDateTo DATE; ) BEGIN // Procedure body ProgramCode:=Program_Code; SourceDateFrom:=Source_Date_From; SourceDateTo:=Source_Date_To; CREATE TEMPORARY TABLE TempReq_Rep AS SELECT * from <base_view> left outer join <dervied view> on <join fields> where ( program_code in (Select Value from split (Program_Code,',') ) AND status IN ('A', 'O', 'P') AND nstatus NOT IN('X') AND (source_date >= SourceDateFrom AND source_date <= SourceDateTo) ); END; Your help is much appreciated
user
09-05-2024 09:53:58 -0400
code

1 Answer

Hello, When you are using a VQL stored procedure to create a table or execute other DDL statements it is necessary to enter the statement as a string enclosed with a single quote proceeded by the command `EXECUTE`. This is likely the reason for the error you are describing. This means you should surround the `CREATE` statement with a set of single quotes and add the command `EXECUTE` as, `EXECUTE 'CREATE TEMPORARY TABLE...'`. I would review the following page of the user manuals for more information on [Developing VQL Stored Procedure](https://community.denodo.com/docs/html/browse/8.0/en/vdp/developer/developing_extensions/developing_stored_procedures/developing_vql_stored_procedures). You may need to make additional changes to have the stored procedure complete your specific desired task. For more detailed assistance with your current situation, we would recommend creating a support case if you have a valid support user. Hope this helps!
Denodo Team
10-05-2024 18:29:11 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here