Re: Custom SQL function does not like IF-statement

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Custom SQL function does not like IF-statement
Date: 2016-09-26 18:26:07
Message-ID: 20160926182607.4fjw2vx4oagu7wzh@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Sep 26, 2016 at 08:22:11PM +0200, Alexander Farber wrote:
> ERROR: syntax error at or near "IF"
> LINE 11: IF LENGTH(TRIM(in_msg)) > 0 AND
> ^

of course it doesn't like it, because sql doesn't have "if" command.

If you want to use such syntax, you have to use plpgsql language for the
function.

Best regards,

depesz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rakesh Kumar 2016-09-26 18:29:43 Re: Incrementally refreshed materialized view
Previous Message Pavel Stehule 2016-09-26 18:25:39 Re: Custom SQL function does not like IF-statement