Re: plpgsql function case statement

Поиск
Список
Период
Сортировка
От Masaru Sugawara
Тема Re: plpgsql function case statement
Дата
Msg-id 20010927022655.642E.RK73@echna.ne.jp
обсуждение исходный текст
Ответ на plpgsql function case statement  ("Peter Schmidt" <peterjs@home.com>)
Список pgsql-sql
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



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Wei Weng"
Дата:
Сообщение: Re: is it possible to get the number of rows of a table?
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: How to enter lists into database: Problems with solution.