偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Oracle 函數(shù)decode的用法簡(jiǎn)介

數(shù)據(jù)庫(kù) Oracle
我們今天主要和大家介紹的是Oracle 函數(shù)decode的實(shí)際用法,我們以實(shí)例的方式來(lái)說(shuō)明其實(shí)際的相關(guān)應(yīng)用,以下就是文章的具體操作。

以下的文章主要是介紹Oracle 函數(shù)decode,我們都知道decode函數(shù)將該數(shù)值和c一系列的相關(guān)序偶相比較來(lái)決定最終的相關(guān)的返回結(jié)果 。所謂的序偶,簡(jiǎn)單的說(shuō)就是成對(duì)的出現(xiàn);我們將這個(gè)函數(shù)與switch比較。

我們發(fā)現(xiàn)他們基本相似,***不同的是switch將要比較的值放在case后面都加上了break中。

以下一個(gè)例子:(我直接從網(wǎng)上找的)

 

  1. SELECT id,  
  2. decode(flag,’Y’,'Yes’,'N’,’No’,NULL,’None’,'Yes’)  
  3. FROM t_test;  

 

當(dāng)t_test的flag字段為Y時(shí)返回Yes,為N時(shí)返回No,為NULL時(shí)返回None,默認(rèn)返回Yes。

看看我遇到的問(wèn)題:

 

  1. SELECT a.id,  
  2. a.user_name,  
  3. a.oper_time time2,  
  4. a.oper_type,  
  5. a.description,  
  6. a.oper_flag,  
  7. decode(a.oper_flag, '1', '成功', '失敗') oper_flag,  
  8. a.ip,  
  9. b.true_name  
  10. FROM SEC_LOG_OPERATION a  
  11. left join sec_user b on a.user_name = b.user_name  
  12. where 11 = 1  
  13. order by oper_time desc  

 

原來(lái)這紅線部分是:

Oracle 函數(shù)decode(a.oper_flag, 1, '成功', '失敗')

我在查詢的時(shí)候會(huì)報(bào)錯(cuò),原因是oper_flag這個(gè)字段數(shù)據(jù)中有非數(shù)字類型,也就是這個(gè)字段不僅有1、0,還有“失敗”,這樣數(shù)據(jù)!=字符。所以我們把1當(dāng)字符處理就可以了。

【編輯推薦】

  1. Oracle join的正確用法描述
  2. Oracle ebs的oaf開(kāi)發(fā)環(huán)境進(jìn)行正確的配置
  3. Oracle reports功不可沒(méi),實(shí)現(xiàn)報(bào)表定長(zhǎng)輸出
  4. 查看Oracle當(dāng)前連接數(shù)的具體方案
  5. 加速Oracle大批量數(shù)據(jù)處理的2個(gè)好用方案
責(zé)任編輯:佚名 來(lái)源: 博客園
相關(guān)推薦

2010-05-10 18:22:28

Oracle deco

2010-04-28 16:53:20

Oracle 函數(shù)

2010-10-25 17:00:40

Oracle deco

2010-11-04 11:45:10

Oracle DECO

2010-04-01 09:56:44

Oracle DECO

2010-04-08 16:41:29

Oracle存儲(chǔ)過(guò)程

2010-11-18 15:46:41

Oracle Deco

2010-04-29 13:31:16

Oracle Orad

2010-10-25 14:28:53

oracle trun

2010-10-25 16:52:48

oracle管道函數(shù)

2010-10-25 15:12:42

Oracle日期函數(shù)

2010-10-25 17:28:05

Oracle bita

2010-04-26 16:51:11

Oracle Deco

2010-04-30 17:58:55

Oracle trun

2010-04-30 10:47:26

Oracle Nvl函

2010-05-04 12:10:08

Oracle over

2010-10-25 16:13:31

Oracle to_d

2010-10-25 17:39:24

Oracle單行日期函

2011-04-12 13:27:09

Oracle日期函數(shù)

2010-10-25 14:47:49

Oracle系統(tǒng)變量函
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)