From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | rod(at)iol(dot)ie |
Cc: | "'PostgreSQL'" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: plpgsql: UPDATE...Returning in FOR loop |
Date: | 2009-03-02 20:19:55 |
Message-ID: | 23607.1236025195@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Raymond O'Donnell" <rod(at)iol(dot)ie> writes:
> I'm wondering if it's possible to use UPDATE...RETURNING, instead of
> SELECT, in a FOR loop like this:
> ...
> I'm guessing that this isn't possible, because when I try it I get the
> following error:
> gti_messaging=> select recipients_for_delivery(5, 'Email', 20);
> ERROR: domain message_type_domain does not allow null values
> CONTEXT: PL/pgSQL function "recipients_for_delivery" line 4 during
> statement block local variable initialization
Well, that has nothing to do with UPDATE RETURNING; it's apparently
failing here:
> rec recipients;
I suppose "recipients" is a composite type one of whose columns is of a
NOT NULL domain. Best advice is "don't do that" --- not-null domains
were not one of the SQL committee's better ideas. If you're really in
love with your existing schema, though, you could probably work around
it by declaring rec as "record" instead of the specific composite type.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Sam Mason | 2009-03-02 20:29:08 | Re: plpgsql: UPDATE...Returning in FOR loop |
Previous Message | Raymond O'Donnell | 2009-03-02 19:34:55 | plpgsql: UPDATE...Returning in FOR loop |