Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    385
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pass-Through Query in Access

    I have an expression written in Access
    Mid([CBP], (InStr(5,[CBP],"~")+1), (IIf((InStr((InStr(5,[CBP],"~")+1),[CBP],"~")-(InStr(5,[CBP],"~")+1))>0,(InStr((InStr(5,[CBP],"~")+1),[CBP],"~")-(InStr(5,[CBP],"~")+1)),0)))

    What I need to do is translate this into SQL so I can use it in a pass-through query connecting to an Oracle database.

    I have the syntax down for everything except the "IIF". Is there an equivalent function in SQL that can be used to complete this expression?


    Thanks for any help.
    Richard

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,058
    Thanks
    196
    Thanked 765 Times in 699 Posts
    Richard,

    While editing the query just switch to SQL view to see how to code it. HTH
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  4. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    385
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I continued to play with it and was able to get this code to work.

    (CASE WHEN ((InStr(CBP,'~',2,2))-(InStr(CBP,'~',2)))>0
    THEN SUBSTR(CBP, (InStr(CBP, '~', 2))+1, ( (InStr(CBP, '~', 2, 2)) - (InStr(CBP, '~', 2))-1 ) )
    ELSE NULL
    END )
    Richard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •