+ New Ticket

syntax errors trying to create a UDF

Comments

3 comments

  • Avatar
    omer brandis
    hi,

    i managed to create a function using a single quote :
    CREATE ...returns .... AS ' function source ' LANGUAGE plpgsql VOLATILE SECURITY DEFINER;


    previously I was trying to use "dollar quoting" as described in the greenplum documentation.

    so i have a workaround,
    but id still love some help regarding "dollar quating",

    thanks
    omer.

    0
    Comment actions Permalink
  • Avatar
    Oleg Popivnenko
    Hi Omer,

    I was able to successfully create a UDF using these steps.

    1. Use Object / User Defined Function / New... menu
    2. Left everything as-is in the window that was opened
    3. Added a sample function body between the two $body$ statements so that the complete content of my SQL editor was like this:

    CREATE OR REPLACE FUNCTION my_new_function()
    RETURNS INTEGER
    AS
    $BODY$
    begin
    return 1;
    end;
    $BODY$
    LANGUAGE plpgsql
    VOLATILE
    CALLED ON NULL INPUT;

    4. Hit F5 to execute that.
    5. The function was successfully created.
    6. Opened a new SQL tab and used this query to make sure the UDF was successfully created:
    select * from my_new_function()

    I hope that helps.
    0
    Comment actions Permalink
  • Avatar
    omer brandis

    thanks oleg.

    0
    Comment actions Permalink

Please sign in to leave a comment.