Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi,
I am trying to write a SQL function in SQL script
CREATE OR REPLACE FUNCTION fun1() RETURNS VOID AS
DECLARE
VAR_VALUE INTEGER;
e RECORD;
BEGIN
for e in select col1,col2 from table
Loop
--BODY OF FUNCTION
END LOOP;
END;
I am getting error while running the code in DECLARE section stating unexpected <EOF>.
Can anyone help me to get rid of this issue and help me in executing the SQL Script for SQL function.
Thanks in advance.
Regards,
Deepak
What SQL engine do you use?
I am using Snowflake
And it's that how you create a SQL function in Snowflake? (ie the correct syntax):
https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql-introduction
It looks like you copied the syntax from this documentation page which is showing how to create a function in PL/pgSQL which is PostgreSQL Procedural languange.
Each SQL engine has it's own SQL syntax, it's own SQL procedural language, etc. You can't mix and match.