I omitted to say that InStr can be used instead of Substr. I think the argument positions are different.
Main Topics
Browse All TopicsHi,
I'm trying to convert the below listed SQL query in MS Access query format. But many functions available in SQL are not used in MS Access (eg: CASE, substr, NVL..etc) ..Could you please assist.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Additionally for CASE, IIF is available in MS Access as Helen indicated with If ... Else structure.
e.g., case structure like
Case
when substr(o.offering_id,1,5) = 'dowbt'
then o.wbt4
else o.ilt4 end
becomes:
IIF(Mid(o.offering_id,1,5)
Notice MS Access uses double quotes (") and MID function can simulate substr(ing) whereas INSTR is more for finding the index of specific character or text within a string. A nice function to be aware of though.
If you have If ... ElseIf ... End type scenarios, just do this:
IIF(Mid(o.offering_id,1,5)
Other things to note, '%abc%' typically in MS Access is "*abc*" to signify a wildcard match to 'abc' with any amount of text around front/back.
Hope that helps.
Regards,
mwvisa1
CDATE == TO_DATE roughly can also look at FORMAT.
Here are some references:
(date conversion / formatting)
http://www.techonthenet.co
http://www.techonthenet.co
(substring)
http://www.techonthenet.co
(case statements)
http://www.techonthenet.co
http://www.techonthenet.co
(nvl / coalesce)
http://www.techonthenet.co
And I meant these parenthesis also, so the join and where clauses. Also try the ODBC canonical format for date.
Also, try REPLACE instead of TRANSLATE:
http://www.techonthenet.co
LEN instead of LENGTH:
http://www.techonthenet.co
PL/SQL LENGTH returns NULL if the value passed is NULL. You may need to use 0 for MS Access.
Sorry I see a type-o with the parenthesis. Thought it was missing the closing one, so I added the ') t' to close it, but it should have been earlier as the alias 'a' is really for the derived table. I was going to fix, but now I see that the original query was altered too much, so will have to start from your own base and apply the techniques I told you. For example, the derived table should only have columns from table a then join to the others. The fields for other tables should be in the outer query.
@mwvisa1
Thanks. I'd missed the closing parens.
Do you have any idea what they are trying to accomplish with the a.learning_hours field manipulation? If non-numeric hours, then how would we be able to sum them?!?
It seems to me that the TRIM function would superfluous if the REPLACE function used an empty string.
Yeah not sure either. I know TRANSLATE is like REPLACE, but possibly it allows regular expression which that is meant to replace all numbers and then that would be making sure that you only have numeric value so possible:
(LEN(TRIM(REPLACE(a.learni
could be replaced with:
(ISNUMERIC(a.learning_hour
http://www.techonthenet.co
And if that is the case, then probably also want to change:
SUM(a.learning_hours)
to:
SUM(CDBL(a.learning_hours)
I think a more reliable method in PL/SQL would be a function like I've pasted into the snippet.
Source: http://psoug.org/reference
________________
I thought I was messing up the typing of changes as I was referring back to the original post but it didn't match. I see now that you corrected the query to be more efficient and my addition of ') t' was appropriate since you made the whole thing a derived table. :) Thought I goofed and that is why I started back from scratch. Nice job. Is it LOWER instead of LCASE?
Thanks for the points.
Note: If you are trying to run a PL/SQL query from an MS-Access database, you don't necessarily have to convert it to Jet SQL. You can save the Oracle SQL in a stored (Access) query that is run as a pass-through query. The Jet engine does not look at the SQL for pass-through queries.
Business Accounts
Answer for Membership
by: Helen_FeddemaPosted on 2009-08-01 at 12:45:00ID: 24996384
Nz can just be substituted for NVL.
The syntax for InStr is: InStr([start,] string1, string2 [, compare])
Select Case is used like this:
Select Case varValue
Case 1
'Some code
Case 2
'Some code
End Select
In your code, with just Null and non-Null alternatives, you could just use an If ... ElseIf ... End if structure instead.