PL/PGSQL help for getting number of rows matched.

From: Rajesh Kumar Mallah <mallah(at)trade-india(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: PL/PGSQL help for getting number of rows matched.
Date: 2003-11-10 10:49:00
Message-ID: 200311101619.00094.mallah@trade-india.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi,

We need to implement following logic efficiently.

SELECT * from some_table where .... [ Query 1 ]

IF rows_matched = 1 THEN

use the single row that matched.

ELSIF

loop thru the results of [Query 1]

END IF;

Currently i am doing select count(*) for getting rows_matched
in the top and repeating the same query in both branches of IF
to get the data of matching rows.

I have tried GET DIAGNOSTICS ROW_COUNT but for
"SELECTS" if returns 0 or 1 based on matching

I am sure there exists better methods. Kindly post a link
to better documentation of pl/pgsql or point out section in
the standard docs that discuss this issue.

Regds
Mallah.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Michel POURE 2003-11-10 10:52:59 Re: Converting SQL-ASCII encoding database to UNICODE
Previous Message Mattias Kregert 2003-11-10 10:34:34 Re: Temp rows - is it possible?