I am trying to create a function in snowflake which have DDL statement inside it. Below is the function.
CREATE OR REPLACE function test_10252021(P1 VARCHAR(100)) returns
varchar not null language javascript as $$ try { `create or replace
temporary table temp_EMP
as
select * from demo_db.public.EMP
where
DEPT_NO='${P1}' `; return "Successful"; } catch(err) { return err.message; } $$ ;
Function is getting created but when I execute below select statement Temp table is not getting created.
Can anyone please help me how to execute ddl statements in function rather than a procedure.
select test_10252021('20');
select * from temp_EMP;