• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Global Temporary Tables And Host Variables, Take 2

    May 31, 2016 Ted Holt

    In Global Temporary Tables and Host Variables, I complained that DECLARE GLOBAL TEMPORARY TABLE does not permit me to use host variables. I presented two ways to circumvent the problem. Today I revisit the topic to show another way that was not available six years ago.

    First, create some global variables.

       create variable somelib.gv_Company   dec(3);
       create variable somelib.gv_Customer  dec(5);
    

    Then use those global variables in your program.

    exec sql
       set gv_Company  = :inCompany;
    exec sql
       set gv_Customer = :inCustomer;
    exec sql
       declare global temporary table Temp1 as
           (select *
              from sales
             where companyno  = gv_Company
               and customerno = gv_Customer)
         with data with replace;
    

    DECLARE GLOBAL TEMPORARY TABLE has no qualms with the use of global variables.

    Global variables are still new to me. I suspect I have not even begun to understand the many ways to use them effectively.

    Ted Holt welcomes your comments and questions. Email him through the IT Jungle Contacts page.

    RELATED STORIES

    New in DB2 for i 7.1: Use Global Variables to Track Environment Settings

    Global Temporary Tables and Host Variables

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Midrange Dynamics North America

    Git up to speed with MDChange!

    Git can be lightning-fast when dealing with just a few hundred items in a repository. But when dealing with tens of thousands of items, transaction wait times can take minutes.

    MDChange offers an elegant solution that enables you to work efficiently any size Git repository while making your Git experience seamless and highly responsive.

    Learn more.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    System i Developer:  RPG & DB2 Summit - October 4-6 2016 in Chicago. Register now!
    NGS:  Webinar: Answering Business Qs with Reporting & Analytics. June 16. RSVP!
    Profound Logic Software:  'i on the Enterprise' Worldwide Virtual Event. June 8. Register Now!

    ProData Gets Graphic, Releases DBU for RDi Fresche Brings the Heat(map) to Legacy Modernization

    Leave a Reply Cancel reply

Volume 16, Number 13 -- May 31, 2016
THIS ISSUE SPONSORED BY:

T.L. Ashford
Valence Framework for IBM i
WorksRight Software

Table of Contents

  • Watch Your Data While Stepping Out With RDi Debug
  • Global Temporary Tables And Host Variables, Take 2
  • LAG And LEAD Functions In DB2 for i 7.3

Content archive

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

Recent Posts

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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