pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marc SCHAEFER <schaefer@alphanet.ch>
Cc: pgsql-sql@postgresql.org
Subject: Re: Various PostgreSQL questions
Date: Mon, 13 May 2002 22:11:18 -0400
Message-ID: <22075.1021342278@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.3.96.1020513183327.11292A-100000@defian.alphanet.ch>
References: <Pine.LNX.3.96.1020513183327.11292A-100000@defian.alphanet.ch>

Marc SCHAEFER <schaefer@alphanet.ch> writes:
> Version: 7.1release-3.potato.1  (Debian package of 7.1release-3)
> Question 1:
>    Apparently using NUMERIC(10, 2) in a type definition (DECLARE) of
>    a stored procedure in PL/pgSQL doesn't work; FLOAT works instead.

I believe this is fixed in 7.2.

> Question 2:
>    How can I implement a constraint which would always ensure the
>    SUM(money_amount) WHERE type = 1 in a specified table is always
>    zero ?

I would think you'd want your function to run AFTER INSERT not
BEFORE INSERT.

>    The following works, once. The second time it doesn't work (in the
>    same session/backend, see below for the error).

If you want to build dynamically-modified queries in plpgsql, you need
to use EXECUTE.  That includes references to tables that you're dropping
and recreating between calls of the function.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <22075.1021342278@sss.pgh.pa.us>
Permalink:  ../22075.1021342278@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22075.1021342278@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, schaefer@alphanet.ch
  Subject: Re: Various PostgreSQL questions
  In-Reply-To: <22075.1021342278@sss.pgh.pa.us>

* 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