Re: [GENERAL] Verifying a timestamp is null or in the past

2012-01-02 Thread Ondrej Ivanič
Hi, On 2 January 2012 03:26, Raymond O'Donnell r...@iol.ie wrote: And also - does PERFORM works with FOUND? Not sure what you mean - can you elaborate? No, perform (and execute) doesn't populate 'found' variable:

Re: [GENERAL] Verifying a timestamp is null or in the past

2012-01-02 Thread David Johnston
On Jan 2, 2012, at 16:46, Ondrej Ivanič ondrej.iva...@gmail.com wrote: Hi, On 2 January 2012 03:26, Raymond O'Donnell r...@iol.ie wrote: And also - does PERFORM works with FOUND? Not sure what you mean - can you elaborate? No, perform (and execute) doesn't populate 'found' variable:

Re: [GENERAL] Verifying a timestamp is null or in the past

2012-01-02 Thread Ondrej Ivanič
Hi 2012/1/3 David Johnston pol...@yahoo.com: On Jan 2, 2012, at 16:46, Ondrej Ivanič ondrej.iva...@gmail.com wrote: Yes, PERFORM does populate FOUND. From the documentation you just linked to A PERFORM statement sets FOUND true if it produces (and discards) one or more rows, false if

Re: [GENERAL] Verifying a timestamp is null or in the past

2012-01-01 Thread Alexander Farber
Hello Ray and others, On Sat, Dec 31, 2011 at 10:26 AM, Raymond O'Donnell r...@iol.ie wrote: # select pref_move_week('DE16290', 'DE1'); ERROR:  query has no destination for result data HINT:  If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT:  PL/pgSQL function

Re: [GENERAL] Verifying a timestamp is null or in the past

2012-01-01 Thread Raymond O'Donnell
On 01/01/2012 14:42, Alexander Farber wrote: Hello Ray and others, On Sat, Dec 31, 2011 at 10:26 AM, Raymond O'Donnell r...@iol.ie wrote: # select pref_move_week('DE16290', 'DE1'); ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-31 Thread Raymond O'Donnell
On 31/12/2011 06:15, Alexander Farber wrote: Hello again, On Fri, Dec 30, 2011 at 2:07 PM, Alban Hertroys haram...@gmail.com wrote: select 1 from pref_users where id=_from and vip current_timestamp + interval '1 week'; if not found then return; end if; unfortunately I get the

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-30 Thread Alexander Farber
Hello again, please 1 more question: can I have a SELECT statement inside of an IF-conditional? The doc http://www.postgresql.org/docs/8.4/static/plpgsql-control-structures.html does not list such an example. I'm asking, because I'd like to get rid of the has_vip variable in my rewritten

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-30 Thread Alban Hertroys
On 29 Dec 2011, at 19:15, Alexander Farber wrote: I'm trying to create PL/pgSQL procedure allowing players with enough vip status left to give a week of it to other users, as a gift: create or replace function pref_move_week(_from varchar, _to varchar) returns void as $BODY$

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-30 Thread Alexander Farber
Awesome advices here. Thank you and happy new year. On Fri, Dec 30, 2011 at 2:07 PM, Alban Hertroys haram...@gmail.com wrote: select 1 from pref_users where id=_from and vip current_timestamp + interval '1 week'; if not found then    return; end if; found is a special pl/psql keyword

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-30 Thread Alexander Farber
Hello again, On Fri, Dec 30, 2011 at 2:07 PM, Alban Hertroys haram...@gmail.com wrote: select 1 from pref_users where id=_from and vip current_timestamp + interval '1 week'; if not found then    return; end if; unfortunately I get the error in PostgreSQL 8.4.9: # select

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-30 Thread Alexander Farber
Is it because my procedure is declared as void? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] Verifying a timestamp is null or in the past

2011-12-29 Thread Alexander Farber
Hello fellow postgres users, in my game using PostgreSQL 8.4.9 players can purchase a VIP (very important person) status: # \d pref_users; Table public.pref_users Column |Type | Modifiers +-+---

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-29 Thread Andreas Kretschmer
Alexander Farber alexander.far...@gmail.com wrote: Hello fellow postgres users, in my game using PostgreSQL 8.4.9 players can purchase a VIP (very important person) status: # \d pref_users; Table public.pref_users Column |Type | Modifiers

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-29 Thread Alexander Farber
Thank you Andreas - now that one case works ok, On Thu, Dec 29, 2011 at 7:44 PM, Andreas Kretschmer akretsch...@spamfence.net wrote: Try if (not coalesce(has_vip, false)) then ... but the other case not: # create or replace function pref_move_week(_from varchar, _to varchar)

Re: [GENERAL] Verifying a timestamp is null or in the past

2011-12-29 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Alexander Farber Sent: Thursday, December 29, 2011 3:01 PM Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Verifying a timestamp is null or in the past Thank you