CASE

Started by c kover 17 years ago5 messagesgeneral
Jump to latest
#1c k
shreeseva.learning@gmail.com

Is there any control structure statement similar to select case ... ? If yes
how to use it. I have tried to use, case when <expression> then <expression>
end, but not worked well as I want to use other control structures and sql
statements to be executed for each case.

Please reply.
Thanks
CPK.

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: c k (#1)
Re: CASE

Hello

Develop PL/pgSQL (PostgreSQL 8.4) has CASE statement. Actual and
older version hasn't nothing similar.

Regards
Pavel Stehule

2008/8/19 c k <shreeseva.learning@gmail.com>:

Show quoted text

Is there any control structure statement similar to select case ... ? If yes
how to use it. I have tried to use, case when <expression> then <expression>
end, but not worked well as I want to use other control structures and sql
statements to be executed for each case.

Please reply.
Thanks
CPK.

#3Bill Moran
wmoran@collaborativefusion.com
In reply to: c k (#1)
Re: CASE

In response to "c k" <shreeseva.learning@gmail.com>:

Is there any control structure statement similar to select case ... ? If yes
how to use it. I have tried to use, case when <expression> then <expression>
end, but not worked well as I want to use other control structures and sql
statements to be executed for each case.

Personally, I don't understand the question.

Perhaps if you provided an example of what you are trying to do with
CASE WHEN and why it doesn't work for you.

It _does_ sound like you need to be using something like pl/pgsql.

--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023

#4c k
shreeseva.learning@gmail.com
In reply to: Bill Moran (#3)
Re: CASE

Hi,
I want to create a function as follows:

case variable=value1
SQL statements
case variable=value2
SQL statements
case else
end of case

CPK

On Tue, Aug 19, 2008 at 5:17 PM, Bill Moran
<wmoran@collaborativefusion.com>wrote:

Show quoted text

In response to "c k" <shreeseva.learning@gmail.com>:

Is there any control structure statement similar to select case ... ? If

yes

how to use it. I have tried to use, case when <expression> then

<expression>

end, but not worked well as I want to use other control structures and

sql

statements to be executed for each case.

Personally, I don't understand the question.

Perhaps if you provided an example of what you are trying to do with
CASE WHEN and why it doesn't work for you.

It _does_ sound like you need to be using something like pl/pgsql.

--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/&lt;http://people.collaborativefusion.com/%7Ewmoran/&gt;

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023

#5Tino Wildenhain
tino@wildenhain.de
In reply to: c k (#4)
Re: CASE

c k wrote:

Hi,
I want to create a function as follows:

case variable=value1
SQL statements
case variable=value2
SQL statements
case else
end of case

Looks like you want to use pl/pgsl and IF ... THEN ... ELSE instead?

Cheers
Tino