assign the row count of a query to a variable

Поиск
Список
Период
Сортировка
От Kevin B.
Тема assign the row count of a query to a variable
Дата
Msg-id 1386.67.87.30.165.1105735384.squirrel@www.ke5in.com
обсуждение исходный текст
Ответы Re: assign the row count of a query to a variable  (PFC <lists@boutiquenumerique.com>)
Re: assign the row count of a query to a variable  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-sql
Hi,

I'm trying to assign the row count of a query to a variable in a function
but I'm not having any luck.

Could someone tell me the syntax? I've been looking in the docs and
googling for a long time but just can't find the answer.

I've tried:
CREATE OR REPLACE FUNCTION ret1() RETURNS int4 AS '
BEGIN
declare
var int4;
begin     --select var count(*) from T;     --select var (count(*)) from T;     --select var = count(*) from T;     var
=select count(*) from T;  return   var;
 
END;
END;
'
LANGUAGE 'plpgsql';



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

Предыдущее
От: KÖPFERL Robert
Дата:
Сообщение: Re: Column with recycled sequence value (solved (somehow))
Следующее
От: PFC
Дата:
Сообщение: Re: assign the row count of a query to a variable