Re: Verifying a timestamp is null or in the past

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Verifying a timestamp is null or in the past
Date: 2012-01-01 16:26:51
Message-ID: 4F00894B.4090205@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 <rod(at)iol(dot)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 "pref_move_week" line 3 at SQL statement
>>>
>>> # create or replace function pref_move_week(_from varchar,
>>> _to varchar) returns void as $BODY$
>>> begin
>>>
>>> select 1 from pref_users
>>> where id=_from and
>>> vip is not NULL and
>>> vip > current_timestamp + interval '1 week';
>>
>> As the error message says, if you don't need the result of the SELECT
>> then do PERFORM instead:
>>
>> perform 1 from pref_users...
>>
>
> I've tried that of course, but "perform 1 ..." fails with 8.4.9:
>
>
> # select 1 from pref_users
> where id='DE1' and
> vip is not NULL and
> vip > current_timestamp + interval '1 week';
> ?column?
> ----------
> 1
> (1 row)
>
> # perform 1 from pref_users
> where id='DE1' and
> vip is not NULL and
> vip > current_timestamp + interval '1 week';
> ERROR: syntax error at or near "perform"
> LINE 1: perform 1 from pref_users

Is this in a pl/pgsql function, or a straight SQL query? PERFORM in this
form is a pl/pgsql construct; you'll get a syntax error if you try it at
the psql command line.

> And also - does PERFORM works with FOUND?

Not sure what you mean - can you elaborate?

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jay Levitt 2012-01-01 18:51:35 9.1.2: Preventing connections / syncing a database
Previous Message Alexander Farber 2012-01-01 14:42:41 Re: Verifying a timestamp is null or in the past