pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Kevin B. <db@ke5in.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: assign the row count of a query to a variable
Date: Fri, 14 Jan 2005 14:15:48 -0700
Message-ID: <20050114211548.GA42739@winnie.fuhr.org> (raw)
In-Reply-To: <1386.67.87.30.165.1105735384.squirrel@www.ke5in.com>
References: <1386.67.87.30.165.1105735384.squirrel@www.ke5in.com>

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/



view thread (3+ messages)

Message-ID: <20050114211548.GA42739@winnie.fuhr.org>
Permalink:  ../20050114211548.GA42739@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050114211548.GA42739@winnie.fuhr.org

 · 

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: mike@fuhr.org, db@ke5in.com
  Subject: Re: assign the row count of a query to a variable
  In-Reply-To: <20050114211548.GA42739@winnie.fuhr.org>

* 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