declaring functions in PostgreSQL

[expired user #10313]'s profile image [expired user #10313] posted 7 years ago in Running SQL scripts Permalink

Sorry, another PostgreSQL question.

Consider the following script:

CREATE OR REPLACE FUNCTION test_function (
    myParam VARCHAR
)
RETURNS INTEGER
AS 

$BODY$
declare
    myVar integer;
begin
    return now();
end;

$BODY$

LANGUAGE plpgsql 
;

When I run in pgAdmin, all is well.

But running it in HeidiSQL, I get the following error message:

CREATE OR REPLACE FUNCTION test_function (
    myParam VARCHAR
)
RETURNS INTEGER
AS 

$BODY$
declare
    myVar integer;

/* ERROR:  unterminated dollar-quoted string at or near "$BODY$
declare
    myVar integer"
LINE 7: $BODY$
        ^ */

It seems like Heidi is not passing the entire statement to the server. Heidi seems to ignore $BODY$ and assumes the statement ends at the first semicolon.

How to fix?

Thanks, Dave

[expired user #10313]'s profile image [expired user #10313] posted 7 years ago Permalink

From what I can tell, Heidi ignores Dollar-quoted String Constants (see www.postgresql.org/docs/current/static/sql-syntax-lexical.html, section 4.1.2.4).

Or am I mistaken?

[expired user #10313]'s profile image [expired user #10313] posted 7 years ago Permalink

Any needs on this? Is this a real bug or am I doing something wrong?

Thanks, DC

Please login to leave a reply, or register at first.