CREATE FUNCTION ERROR

AlokTAlokT Community Edition User
edited September 2020 in General Discussion

CREATE FUNCTION replaceSpChar (x VARCHAR)
RETURN VARCHAR
AS BEGIN
RETURN REGEXP_REPLACE (x, '[.,;‘`:/*()
?/"&%$!+={}<>]', '') end

END

ERROR 4856: Syntax error at or near "end" at character 128

This manual select works->
select REGEXP_REPLACE ('?' , '[.,;‘`:/*()
?/"&%$!+={}<>]', '')

Answers

  • SruthiASruthiA Administrator

    @AlokT: Semicolon is missing in your CREATE statement before END. Please find working example below

    dbadmin=> CREATE FUNCTION replaceSpChar (x VARCHAR) RETURN VARCHAR AS BEGIN RETURN REGEXP_REPLACE (x, '[.,;‘`:/*()?/"&%$!+={}<>]', ''); end;
    CREATE FUNCTION
    dbadmin=>

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file