Ads were blocked by your webbrowser.

This is not a problem, but keep in mind that developing HeidiSQL, user support and hosting takes time and money.

You may want to send a donation instead.

declaring functions in PostgreSQL

dcherk's profile image dcherk posted 3 years ago in Running SQL scripts

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

dcherk's profile image dcherk posted 3 years ago

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?

dcherk's profile image dcherk posted 3 years ago

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.