CASE conversion from IIF

淺唱寂寞╮ 提交于 2019-12-20 06:41:06

问题


I started off with SQL (access)

IIf(Len([CAT]) < 3, 
Left([CAT],1) & 0 & Right([CAT],1),
[CAT]) AS CAT1, 
[HD0] &

IIf([TABLE].[HD1]<>"00",
" / " & [HD1_ABR],
Null) & 
IIf([HD2]<>"00",
" / " & [HD2_NAME],
Null) & 
IIf([HD3]<>"000",
" / " & [HD3_NAME],
Null) & 
IIf([HD4]<>"00",
" / " & [HD4_NAME]) AS NAME,

and did Oracle (Sql Developer)

Case
When length(cat) < 3
Then SubStr(cat,1,1) || '0' || SubStr(cat,-1,1)
Else cat
End cat1,hd0
Case
When TABLE <>"00"
then " / "
else HD1_ABR,null

When I run query in SQLDev I get error Error at Command Line:9 Column:4 Error report: SQL Error: ORA-00923: FROM keyword not found where expected 00923. 00000 - "FROM keyword not found where expected"


回答1:


MS Access syntax is entirely different to Oracle syntax. No square brackets, and different names for the SQL functions. http://docs.oracle.com/cd/E11882_01/server.112/e17118/functions.htm#SQLRF006

 Case
   When length(cat) < 3
   Then SubStr(cat,1,1) || '0' || SubStr(cat,-1,1)
   Else cat
 End cat1


来源:https://stackoverflow.com/questions/15506710/case-conversion-from-iif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!