assign the row count of a query to a variable - Mailing list pgsql-sql

From Kevin B.
Subject assign the row count of a query to a variable
Date
Msg-id 1386.67.87.30.165.1105735384.squirrel@www.ke5in.com
Whole thread Raw
Responses Re: assign the row count of a query to a variable
Re: assign the row count of a query to a variable
List 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 by date:

Previous
From: KÖPFERL Robert
Date:
Subject: Re: Column with recycled sequence value (solved (somehow))
Next
From: PFC
Date:
Subject: Re: assign the row count of a query to a variable