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

2012-01-02 Thread Ondrej Ivanič
Hi 2012/1/3 David Johnston : > On Jan 2, 2012, at 16:46, Ondrej Ivanič 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 no row is produced. > Bummer! Tha

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č wrote: > Hi, > > On 2 January 2012 03:26, Raymond O'Donnell 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: > http://www.postgresql.o

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 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: http://www.postgresql.org/docs/9.0/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIA

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 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 PE

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 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 "pref_mo

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 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 g

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

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 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 pref_move_week('D

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 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 that tel

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
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 procedu

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

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 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) returns void as $BODY$

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

2011-12-29 Thread Andreas Kretschmer
Alexander Farber 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 > +-

[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 +-+---