title: Syntax Error 42561. ERROR: syntax error at or near ";"
body: <p>I've been receiving a syntax error on my create function statement and no matter what I try, I can't seem to find why it shows this error.</p>
  
  <p>Here is the part of the code that shows the error:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION public.fnc_Name(
      param character varying)
   RETURNS json
  AS $BODY$
  
  Declare
  --VAriables
     _result varchar;
     _error_code varchar;
     _error_msg varchar;
  
  BEGIN
  
  --redacted code
  
      BEGIN
      exception when OTHERS then
          _result = -1;
          _error_code = 130;
              GET STACKED DIAGNOSTICS _error_msg = MESSAGE_TEXT;    
              SELECT json_build_object('status', _status , 'error_code' , 
      _error_code, 'error_message', _error_msg) INTO _result;
      return _result;
      END;
  
  END; --Error shows at this ; 
  $BODY$
  LANGUAGE plpgsql;
  </code></pre>