• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Away With The SQL Slash Separator

    June 19, 2013 Michael Sansoterra

    One potentially confusing aspect of programming SQL in DB2 for i for non-IBMers is the use of the forward slash character to qualify an SQL object with a schema. IBM i devs don’t have a problem with the slash because we recognize it as the character we use when qualifying objects while tooling around the i/OS green screen. Others database devs may wonder what sophisticated function the slash serves. However, in IBM i 7.1, IBM introduced a change in DB2 Group PTF SF99701 Level 15 that is worth noting.

    When using the system naming convention, developers can now use either a dot (.) or a slash (/) to separate a schema and object name. Here are a few examples:

    /* Table or view name */
    SELECT * FROM PRODLIB.ITEMS
    
    /* Table Function */
    SELECT * 
      FROM TABLE(PRODLIB.ORDER_REVISION(ORDER_NUM)) ORDER_REV
    
    /* Scalar Function */
    SELECT ITEM,PRODLIB.CUR_PRICE(CUSTOMER,SALE_DATE)  
    AS CURRENT_PRICE FROM ORDER_HISTORY
    
    /* Procedure Call */
    CALL PRODLIB.GET_ITEMS
    

    This change to use the dot separator is beneficial for a number of reasons:

    • Most database management systems use the dot notation.
    • Most client/server tools (JDBC, ODBC, OLE DB, .NET) default to use the dot notation.
    • Using the dot makes writing portable code easier (and it will be code that non-“DB2 for i” devs will understand).
    • You can take advantage of the benefits of the system naming convention’s library list search.
    • Table and scalar user-defined function names can now be qualified with a schema (a.k.a., library) even when the system naming convention is used. In the past, you couldn’t qualify a UDF when using the system naming convention.
    • You can interchange the same SQL statement between different tools that default to *SQL and *SYS without having to change the blasted separator character.

    At the time of this writing, there is one caveat; the latest IBM i ODBC driver may not be up to snuff when handling this change. I was hoping to use this new feature with a SQL Server linked server using the ODBC driver. Using the dot separator with the system naming convention would allow me to use the four-part naming convention when accessing DB2 data, as well as allowing me to call stored procedures and dynamic SQL statements that use the library list.

    Similarly, I was unable to use an earlier version of the IBMDASQL OLE DB provider with the SQL Server “dual purpose” linked server either, but an IBM rep tried it with the latest i Access service pack (-SI47412) and was able to make it work. (Because I was running my tests on Windows 8, I couldn’t upgrade to the latest SP). Hopefully, this problem in the ODBC driver will be removed in one of the upcoming service packs.

    In short, it’s advantageous to forget the slash separator when coding SQL. Fortunately, we can now do this and still maintain the benefit of the library list where applicable.

    Michael Sansoterra is a DBA for Broadway Systems in Grand Rapids, Michigan. Send your questions or comments for Mike via the IT Jungle Contact page.



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Profound Logic Software:  Live Webinar: How to Take IBM i Everywhere with Mobile Apps. June 26
    Maxava:  Webinar: Business Continuity For The 21st Century. June 20.
    Abacus Solutions:  Qualified IBM i users eligible for free pair of running shoes

    More IT Jungle Resources:

    System i PTF Guide: Weekly PTF Updates
    IBM i Events Calendar: National Conferences, Local Events, and Webinars
    Breaking News: News Hot Off The Press
    TPM @ The Reg: More News From ITJ EIC Timothy Prickett Morgan

    StorageQuest Uses Flash Memory in VTL Silver Anniversary For Silverlake

    Leave a Reply Cancel reply

Volume 13, Number 12 -- June 19, 2013
THIS ISSUE SPONSORED BY:

Bug Busters Software Engineering
SEQUEL Software
WorksRight Software

Table of Contents

  • Creating And Using i Project
  • Away With The SQL Slash Separator
  • Removing Members From And Deleting An i OS Group Profile

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle