PostgreSQL User Defined Functions

  • Comments posted to this topic are about the item PostgreSQL User Defined Functions

  • Thank you for the article. This is nicely explained. However I have a couple of questions.

    The basic template is

    CREATE [OR REPLACE] FUNCTION function_name (arguments) 
    RETURNS return_datatype AS $variable_name$
    DECLARE
    declaration;
    [...]
    BEGIN
    < function_body >
    [.. logic]
    RETURN { variable_name | value }
    END;
    LANGUAGE language_name;

    I saw return datatype as $$ and did not see a variable name there

    Also in one of your examples the language was not listed after the END keyword.

    Are these differences the same or somehow different from what the template presents?

    ----------------------------------------------------

  • The $$ is a delimiter you use to indicate where the function definition starts and ends.

    The language can also be listed after the 'returns' keyword before the start of the function definition. It works just fine.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply