Re: [GENERAL] Custom SQL function does not like IF-statement

2016-09-26 Thread Alexander Farber
Sorry, I've just realized you did that already. And the WITH cte AS part is optional in this case... Thank you On Mon, Sep 26, 2016 at 9:12 PM, Alexander Farber < alexander.far...@gmail.com> wrote: > Thank you Vik and others - > > On Mon, Sep 26, 2016 at 8:43 PM, Vik Fearing wrote: > >> On 09/

Re: [GENERAL] Custom SQL function does not like IF-statement

2016-09-26 Thread Alexander Farber
Thank you Vik and others - On Mon, Sep 26, 2016 at 8:43 PM, Vik Fearing wrote: > On 09/26/2016 08:22 PM, Alexander Farber wrote: > > > > CREATE OR REPLACE FUNCTION words_get_chat( > > in_uid integer, > > in_gid integer, > > in_msg varchar > >

Re: [GENERAL] Custom SQL function does not like IF-statement

2016-09-26 Thread Vik Fearing
On 09/26/2016 08:22 PM, Alexander Farber wrote: > Good evening! > > For a 2-player game I am trying to create a custom SQL function, which > stores a new message (if not empty) into words_chat table and then > return all messages from that table for a given game: > > CREATE OR REPLACE FUNCTION wo

Re: [GENERAL] Custom SQL function does not like IF-statement

2016-09-26 Thread hubert depesz lubaczewski
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 plp

Re: [GENERAL] Custom SQL function does not like IF-statement

2016-09-26 Thread Pavel Stehule
Hi 2016-09-26 20:22 GMT+02:00 Alexander Farber : > Good evening! > > For a 2-player game I am trying to create a custom SQL function, which > stores a new message (if not empty) into words_chat table and then return > all messages from that table for a given game: > > CREATE OR REPLACE FUNCTION

[GENERAL] Custom SQL function does not like IF-statement

2016-09-26 Thread Alexander Farber
Good evening! For a 2-player game I am trying to create a custom SQL function, which stores a new message (if not empty) into words_chat table and then return all messages from that table for a given game: CREATE OR REPLACE FUNCTION words_get_chat( in_uid integer,