0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ストプロでIFを書くのが面倒な時の書き方(CASE WHEN)

0
Posted at

うちの会社ではストプロが主流みたいでぼちぼち書く機会があるんだけど、
コードレビューいただいた時に、書き方を教わったのでメモ。

普通にIFで書く時

IF w_no_target_content IS NOT NULL AND w_no_target_content <> '' THEN
    w_result.no_target_content = w_no_target_content;
  END IF;

今回教わった書き方

CASE WHEN w_no_target_content IS NOT NULL AND w_no_target_content <> '' THEN     w_result.no_target_content = w_no_target_content END

一行で書けていい感じに…!!ELSEも書けるよ。
rubyでだと後置IFとか三項演算子とかで書いてたから同じような書き方ができないかなーと思ったりしてたからよかった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?