Re: Query execution based on a condition

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'JORGE MALDONADO'" <jorgemal1960(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Query execution based on a condition
Date: 2012-12-29 19:23:35
Message-ID: 00a101cde5f9$ff5461f0$fdfd25d0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-owner(at)postgresql(dot)org]
On Behalf Of JORGE MALDONADO
Sent: Saturday, December 29, 2012 2:06 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] Query execution based on a condition

I have a query similar to the one shown below but, depending on the value of
a field, only the first SELECT statement shoud execute and the other 3
should be ignored. Is there a way to achieve this situation?

SELECT fields FROM tblTable WHERE condition

UNION

SELECT fields FROM tblTable WHERE condition

UNION

SELECT fields FROM tblTable WHERE condition

UNION

SELECT fields FROM tblTable WHERE condition

Respectfully,

Jorge Maldonado

Not using pure SQL. pl/pgsql provides you access to conditionals and flow
control so you should be able to create a function to do precisely what you
need.

David J.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message msi77 2012-12-29 19:36:56 Re: Query execution based on a condition
Previous Message JORGE MALDONADO 2012-12-29 19:05:35 Query execution based on a condition