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

From: Miguel Ángel MF <michelangelo13(at)gmail(dot)com>
To: eus(at)member(dot)fsf(dot)org
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:21:58
Message-ID: ef447e890902200521g216a521ai3619eac7ac682559@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm no expert, but:
i might say U should Escape the ` ' ´ char in "(select split_part(category,
'-', 2) " using something like "(select split_part(category, \'-\', 2)" or
however it should be...

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

http://www.brainyquote.com/quotes/authors/m/muhammad_ali.html

http://www.brainyquote.com/quotes/authors/e/emma_goldman.html

http://www.brainyquote.com/quotes/authors/m/michelangelo.html

Bill Watterson - "There is not enough time to do all the nothing we want to
do."

On Fri, Feb 20, 2009 at 2:02 PM, Eus <eus(at)member(dot)fsf(dot)org> wrote:

> Hi Ho!
>
> The following query works well:
>
> select count (*)
> from item_audit
> where audit_ts >= '2008-05-30 00:00:00'
> and audit_ts <= '2008-10-30 00:00:00'
> and 'wst' != (select split_part(category, '-', 2)
> from description
> where split_part(category, '-', 1) = 'item'
> and shorthand = status
> )
>
> But, when I transform it into the following SQL function, the function
> cannot be created barking:
>
> ERROR: syntax error at or near "-"
> LINE 6: and $1 != (select split_part(category 2)"
>
> create or replace function get_I(text, timestamp, timestamp) returns
> bigint as
> 'select count (*)
> from item_audit as ia
> where audit_ts >= $2
> and audit_ts <= $3
> and $1 != (select split_part(category, '-', 2)
> from description
> where split_part(category, '-', 1) = 'item'
> and shorthand = ia.status
> )
> ' language sql;
>
> What's wrong?
>
> Thank you.
>
> 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
>
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ketema Harris 2009-02-20 13:22:36 Re: Why I cannot call a function from within an SQL function?
Previous Message A. Kretschmer 2009-02-20 13:17:22 Re: Why I cannot call a function from within an SQL function?