From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | "Kevin B(dot)" <db(at)ke5in(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: assign the row count of a query to a variable |
Date: | 2005-01-14 21:15:48 |
Message-ID: | 20050114211548.GA42739@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, Jan 14, 2005 at 03:43:04PM -0500, Kevin B. wrote:
> I'm trying to assign the row count of a query to a variable in a function
> but I'm not having any luck.
Please be more specific than "not having any luck." What are you
expecting to happen and what actually does happen?
> 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.
See the "Basic Statements" and "Expressions" sections of the PL/pgSQL
documentation. Either of the following should work:
var := count(*) FROM T;
SELECT INTO var count(*) FROM T;
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | PFC | 2005-01-15 08:26:22 | Re: SQL Query Performance tips |
Previous Message | Joel Fradkin | 2005-01-14 21:15:02 | I am writing a MS SQL server conversion utility and am having an issue with timestamp |