-1

hi I'm unable to create this function, it throws me an error "syntax error near int". I'm using redshift

CREATE OR REPLACE FUNCTION stage.calc_enddate( int, int, timestamp)
    RETURNS timestamp
    LANGUAGE sql
    STABLE
AS $$
declare
 p int := 0;
begin 
    if ($1 >1) then
        select $3       
    end if
end
    
$$;

thanks in advance Sundar

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
sundarls
  • 3
  • 2
  • I think that `int` shouldn't be there. For some examples, see: [Redshift stored procedure - Add single quoted value in a variable](https://stackoverflow.com/q/57655621/174777) – John Rotenstein Jul 20 '22 at 06:07

1 Answers1

0

According to Amazon Redshift's guide to the link

Data types


    CREATE OR REPLACE FUNCTION stage.calc_enddate(INT, INT, TIMESTAMP)
        RETURNS TIMESTAMP
    stable
    AS $$
    begin 
        if ($1 >1) then
            select $3       
        end if
    end
        
    $$ language sql;

Courser Xu
  • 142
  • 4