Catch multiple records when doing Select Into

From: "SunWuKung" <Balazs(dot)Klein(at)t-online(dot)hu>
To: pgsql-general(at)postgresql(dot)org
Subject: Catch multiple records when doing Select Into
Date: 2006-10-31 09:15:32
Message-ID: 1162286132.537469.8770@m7g2000cwm.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a SELECT INTO varname columname FROM ... statement and I would
like to raise an exception when that returns more than one record.
GET DIAGNOSTICS rowcount = ROW_COUNT seems to return always one for
this. Currently I find no other way to do that than to run this
statement twice - first to see how many records it returns, which seems
very inefficient.

I can see that this will be handled for 8.2, but for 8.1 what is the
best practice to do this?

Thanks.
SWK

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tim Tassonis 2006-10-31 12:57:57 Re: WAL Archiving under Windows
Previous Message Albe Laurenz 2006-10-31 08:32:51 Re: postgres import