Обсуждение: create function with dollar quoted body

Поиск
Список
Период
Сортировка

create function with dollar quoted body

От
Jack Douglas
Дата:
I don't know if this is a netbeans problem or a jdbc problem, but when
executing a 'CREATE FUNCTION' script with the body dollar quoted, an
error results.

Reading around this seems to be to do with the script being parsed for
semicolons as line terminators even inside dollar-quoted strings? Or
perhaps not?

Any pointers much appreciated

Thanks
Jack

Re: create function with dollar quoted body

От
Florent Guillaume
Дата:
Hi,

Please give a code example reproducing the problem you see.

Thanks

On Fri, Mar 9, 2012 at 9:06 PM, Jack Douglas
<jack@douglastechnology.co.uk> wrote:
> I don't know if this is a netbeans problem or a jdbc problem, but when
> executing a 'CREATE FUNCTION' script with the body dollar quoted, an
> error results.
>
> Reading around this seems to be to do with the script being parsed for
> semicolons as line terminators even inside dollar-quoted strings? Or
> perhaps not?
>
> Any pointers much appreciated
>
> Thanks
> Jack
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc



--
Florent Guillaume, Director of R&D, Nuxeo
Open Source, Java EE based, Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87

Re: create function with dollar quoted body

От
Jack Douglas
Дата:
Hi
> Please give a code example reproducing the problem you see.
This works fine:

create or replace function f() returns text language plpgsql as 'begin
return ''A''; end;';

But this fails with "unterminated dollar-quoted string":

create or replace function f() returns text language plpgsql as $$begin
return 'A'; end;$$;

It is not a general problem with dollar-quoting because this works:

create or replace function f() returns text language plpgsql as 'begin
return $$A$$; end;';

Thanks
Jack

Re: create function with dollar quoted body

От
Thomas Kellerer
Дата:
Jack Douglas wrote on 09.03.2012 21:06:
> I don't know if this is a netbeans problem or a jdbc problem, but when
> executing a 'CREATE FUNCTION' script with the body dollar quoted, an
> error results.

It is a NetBeans problem. If the statement is parsed correctly there is no problem creating a function through JDBC

Thomas


Re: create function with dollar quoted body

От
Florent Guillaume
Дата:
Please provide actual Java code.

Florent

On Sat, Mar 10, 2012 at 8:13 PM, Jack Douglas
<jack@douglastechnology.co.uk> wrote:
> Hi
>> Please give a code example reproducing the problem you see.
> This works fine:
>
> create or replace function f() returns text language plpgsql as 'begin
> return ''A''; end;';
>
> But this fails with "unterminated dollar-quoted string":
>
> create or replace function f() returns text language plpgsql as $$begin
> return 'A'; end;$$;
>
> It is not a general problem with dollar-quoting because this works:
>
> create or replace function f() returns text language plpgsql as 'begin
> return $$A$$; end;';
>
> Thanks
> Jack
>


--
Florent Guillaume, Director of R&D, Nuxeo
Open Source, Java EE based, Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87