
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Move your Oracle CASE logic to QlikView side.
.png)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks very much Miguel - i'll give that a try!
Thanks again,
simon

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
