Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

CASE statement when selecting data from Oracle

Hi Everyone, I'm new to extracting data from Oracle db's. Have done a fair amount with SQL.

I'm trying to load data from an Oracle db using the following load scrip but get the "FROM keyword not found where expected" error. I know this script would work when referencing a SQL db. Any ideas\help would be most appreciated.

ODBC



CONNECT TO [HDBP;DBQ=HDBP] (XUserId is fEWfXEZJTaXEVCFIEaTcEGFLdE, XPassword is UXbWAJVMBDZeEXRNZDNSEHNKJF);





SELECT "COMPUTER_NAME" as NBNAME,

"OPERATING_SYSTEM",

"SERIAL_NUMBER",

"DEPARTMENT" =

CASE

WHEN TYPE = 'Laptops' THEN 'EUC'

WHEN TYPE = 'Workstations' THEN 'EUC'

ELSE 'Unasssigned'

END

FROM SIU.WORKSTATION;



5 Replies
Not applicable
Author

Move your Oracle CASE logic to QlikView side.

Miguel_Angel_Baeyens

Hello,

Sometimes the drivers don't pass on the database manager some instructions, but you can get something very similar by doing

Computers:LOAD NBNAME, "OPERATING_SYSTEM", "SERIAL_NUMBER", IF(MATCH("TYPE", 'Workstations', 'Laptops') > 0, 'EUC', 'Unassigned') AS DEPARTMENT;SQL SELECT "COMPUTER_NAME" as NBNAME,"OPERATING_SYSTEM","SERIAL_NUMBER","TYPE"FROM SIU.WORKSTATION;


Hope that helps.

Anonymous
Not applicable
Author

Thanks very much Miguel - i'll give that a try!

Thanks again,

simon

nstefaniuk
Creator III
Creator III

Hi, the correct syntax in Oracle is:



SELECT "COMPUTER_NAME" "NBNAME",
"OPERATING_SYSTEM",
"SERIAL_NUMBER",
CASE
WHEN TYPE = 'Laptops' THEN 'EUC'
WHEN TYPE = 'Workstations' THEN 'EUC'
ELSE 'Unasssigned'
END "DEPARTMENT"
FROM SIU.WORKSTATION;


Anonymous
Not applicable
Author

I think this should work:
SELECT "COMPUTER_NAME" as NBNAME,
"OPERATING_SYSTEM",
"SERIAL_NUMBER",
CASE
WHEN TYPE = 'Laptops' THEN 'EUC'
WHEN TYPE = 'Workstations' THEN 'EUC'
ELSE 'Unasssigned'
END as "DEPARTMENT"
FROM SIU.WORKSTATION;