pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Masaru Sugawara <rk73@echna.ne.jp>
To: pgsql-sql@postgresql.org
Subject: Re: plpgsql function case statement
Date: Thu, 27 Sep 2001 02:27:25 +0900
Message-ID: <20010927022655.642E.RK73@echna.ne.jp> (raw)


Peter Schmidt wrote:

>I'm having trouble finding the best solution for the following plpgsql
>function.
>The function does the following:


Hi, I post in this mailing list for the first time. :-)
I think your pl/pgsql function runs properly, but there 
is likely to exist another SQL pattern. In this case, 
estimation of whether the TIMESTAMP value or NULL 
is finished at one time.
Please try it, if you have time for checking.


(on v7.1.3)

create function updateLastUsed(text, text)
returns integer
as
        '
        declare
                wm integer;
                rows_updated integer;
        begin
                rows_updated := 0;
                wm := getHighmark($1,$2);
             --------------------------------------------------------------
                UPDATE info SET
                lastused = (SELECT  case when MAX(p.requesttime) is null
                                           then info.firstused
                                         else MAX(p.requesttime)
                                    end
                               FROM  usage_log p
                               WHERE p.id = info.id AND p.seq_no >= wm
                            )
             --------------------------------------------------------------
                return rows_updated;
        end;
        '
language 'plpgsql';



--------------------
M.Sugawara
rk73@echna.ne.jp




view thread (2+ messages)

Message-ID: <20010927022655.642E.RK73@echna.ne.jp>
Permalink:  ../20010927022655.642E.RK73@echna.ne.jp/
Also on:    postgresql.org/message-id/20010927022655.642E.RK73@echna.ne.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rk73@echna.ne.jp
  Subject: Re: plpgsql function case statement
  In-Reply-To: <20010927022655.642E.RK73@echna.ne.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox