user2186876
user2186876

Reputation: 3

CASE conversion from IIF

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"

Upvotes: 0

Views: 1337

Answers (1)

David Aldridge
David Aldridge

Reputation: 52376

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

Upvotes: 2

Related Questions