Re: Why I cannot call a function from within an SQL function?

From: Eus <eus(at)member(dot)fsf(dot)org>
To: Marc Schablewski <ms(at)clickware(dot)de>
Cc: Postgresql General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why I cannot call a function from within an SQL function?
Date: 2009-02-20 13:44:44
Message-ID: 653332.30087.qm@web37601.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Ho!

--- On Fri, 2/20/09, Marc Schablewski <ms(at)clickware(dot)de> wrote:

> You are using old-style function declaration where the
> function body is
> given as a string enclosed in '. You have to escape all
> ' inside the
> body by doubling them.

Ah, yes, after re-reading the doc, I found:

--- 8< ---
The syntax of the CREATE FUNCTION command requires the function body to be written as a string constant. It is usually most convenient to use dollar quoting (see Section 4.1.2.2) for the string constant. If you choose to use regular single-quoted string constant syntax, you must double single quote marks (') and backslashes (\) (assuming escape string syntax) in the body of the function (see Section 4.1.2.1).
--- 8< ---

I really missed it. Sorry for making noise.

> As an alternative, you can use $$ as
> the begin
> and end markers of your function body instead of the '
> then you don't
> need to escape.

Yes, this is much better.

Thank you very much for your explanation.

Best regards,
Eus (FSF member #4445)

In this digital era, where computing technology is pervasive, your freedom depends on the software controlling those computing devices.

Join free software movement today! It is free as in freedom, not as in free beer!

Join: http://www.fsf.org/jf?referrer=4445

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Figueiredo Jr. 2009-02-20 14:15:23 Re: Question about functions that return a set of records
Previous Message Eus 2009-02-20 13:41:54 Re: Why I cannot call a function from within an SQL function?