• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Guru: Odds And Ends

    May 14, 2018 Ted Holt

    Little things can make a big difference. Today I am pleased to present a few short tips that may make a difference for you. I hope you get something useful here. If you have short tips that you would like to share with your fellow readers, please email them to me and I’ll see what I can do. Have a wonderful day!


    Hey, Ted:

    I just read your article More Date And Time Conversions Using SQL. Just as aside, the scalar functions Decimal/Dec, Integer, and BigInt can convert times, dates and timestamps directly into a numeric representation in the ISO format, i.e. YYYYMMDD, HHMMSS, YYYYMMDDHHMMSS,NSNSNS. This feature was introduced sometime with release 7.2. Here’s an example:

    With x (MyDate, MyTime, NumDate, NumTime, MyTimestamp)
           as (Values
                 (Current_Date,
                  Current_Time, 
                  Cast(20180327 as Dec(8, 0)),
                  Cast(100000 as Dec(6, 0)),
                  Current_Timestamp),
                 ('2018-03-01', 
                  '12.00.00',
                  Cast(20180301 as Dec(8, 0)),
                  Cast(235659 as Dec(6, 0)),
                  '20180301043025'))
    Select Dec(MyDate)                  DateNum,
           Integer(MyDate)              DateInt,
           Dec(MyTime)                  TimeNum,
           Dec(MyTimestamp)             TsNum,
           Dec(MyTimestamp, 26, 12)     TsNum12,
           BigInt(MyTimestamp)          TsBigInt,
           Dec(Date(MyTimestamp))       TsDateNum,
           Dec(Time(MyTimestamp), 6, 0) TsTimeNum,
           x.*
      from x;   
    

    –Birgitta Hauser

    Thank you, Birgitta. I did not know that those functions would convert date-time data.


    I read Susan Gantner’s article on using RDI debug without SEP’s. I sometimes like to use this method but I have one problem. Here is the scenario:

    I go into Debug Configurations | IBMi Debug Job and create a new debug configuration. I specify the qualified job name, select the programs I want to debug, and click Apply, then Debug. Later on I want to add another program to debug. When I go back into the debug configuration I just created and try to add another program and click Apply, the system tells me the job is already being debugged. How can I add another program to debug?

    –Greg

    The way I most commonly add programs to an existing debug session, whether it’s an SEP-started session or a configuration-started session, is that I step into (F5) the program on a call from one of the programs I’m already debugging. That automatically adds the program to the debug session and opens the source for me to add breakpoints.

    If it’s not feasible or practical for you to step into the program you want to add to a debug session, you can also use the Programs view/tab in the upper right side of the debug perspective (assuming yours still looks vaguely close to the default debug perspective.) I’ve attached a picture of the Programs view – it’s only present in the debug perspective when a debug session is active. There you can see what programs are in debug for the session already and you can add more. Add more by pressing the green plus sign (+) in the toolbar (upper right) and put in the program name. You can use a qualified name if necessary to get the right one.

    After you’ve added a program, you may want to open the source in order to set a breakpoint in the code. A quick way to do that is to expand the program a couple of times until you get down to the level with .RPG (or whatever language it is), then double click to open the source. Now you can add breakpoints and go on with your debug session.

    –Susan Gantner


    Hey, Ted:

     I have another fun request for you, one I’m guessing you’ve already done many, many times. Using an SQL statement, I need to remove any character that is not a letter or digit from a column in a table. Everything else must go.

    –Evan

    This is another good use of regular expressions, Evan. I can illustrate with telephone numbers, which in the United States are made up of 10 digits. However, letters are assigned to digits 2 through 9 to provide an alternate way of representing a phone number.

    Here’s some sample data.

    declare global temporary table temp
     (Phone char(24)) with replace     
    insert into session.temp values
    ('9374397925'),                
    ('800LOVEMYI'),                
    ('800 IBM SERV'),              
    ('(662) 324-0374')             
    

    Here’s a query that shows the regular expression you need:

    select phone, regexp_replace(phone,'[^0-9A-Za-z]','')
      from session.temp                                  
    

     

    PHONE REGEXP_REPLACE
    9374397925 9374397925
    800LOVEMYI 800LOVEMYI
    800 IBM SERV 800IBMSERV
    (662) 324-0374 6623240374

    See Michael Sansoterra’s marvelous article about regular expressions for more information.


    I’ll finish with a short LPEX tip.

    You’re using LPEX to edit a CL program. You need to declare a variable that can hold 24 values of 72 bytes each. How do you calculate the size of that variable?

    You have several options.

    1. You can multiply 24 times 72 in your head. (Yeah, right.)
    2. You can grab a piece of paper and a pencil and work the problem as you did in third grade. (How quaint!)
    3. You can open the calculator application in Windows or your cell phone.
    4. You can open a calculator in a Web browser.
    5. You can reach into or across your desk for a calculator.

    But those methods take too much time. The quick way is to press the Esc key to position within the command line, type calc 24 * 72, and press Enter.

    LPEX displays the answer in decimal and hexadecimal on the message line, which is just above the command line.

    Can’t see the message line? Type set messageline on into the command line and press Enter.

    Want to turn on the message line by default? set default.messageline on

    Calc supports decimal and hexadecimal literals, the usual unary and binary math operators, min and max functions, bitwise functions, trigonometric functions, and a random number function. For more information, visit the IBM Knowledge Center.

    RELATED STORIES

    More Date And Time Conversions Using SQL

    RDI debug without SEP’s

    IBM Knowledge Center – calc command

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: FHG, Four Hundred Guru, Guru, IBM i

    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

    Boston Power9s Set To Debut What’s Cooking With IBM i On GitHub?

    One thought on “Guru: Odds And Ends”

    • B. Robbins says:
      May 14, 2018 at 3:10 pm

      LOL @ that last phone number in your regex example.

      Reply

    Leave a Reply Cancel reply

TFH Volume: 28 Issue: 36

This Issue Sponsored By

  • Maxava
  • ProData Computer Services
  • Software Concepts
  • MiTEC 2018
  • WorksRight Software

Table of Contents

  • Getting Hyper And Converged With IBM i
  • What’s Cooking With IBM i On GitHub?
  • Guru: Odds And Ends
  • Boston Power9s Set To Debut
  • IBM i PTF Guide, Volume 20, Number 19

Content archive

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

Recent Posts

  • The Power11 Transistor Count Discrepancies Explained – Sort Of
  • Is Your IBM i HA/DR Actually Tested – Or Just Installed?
  • Big Blue Delivers IBM i Customer Requests In ACS Update
  • New DbToo SDK Hooks RPG And Db2 For i To External Services
  • IBM i PTF Guide, Volume 27, Number 33
  • Tool Aims To Streamline Git Integration For Old School IBM i Devs
  • IBM To Add Full System Replication And FlashCopy To PowerHA
  • Guru: Decoding Base64 ASCII
  • The Price Tweaking Continues For Power Systems
  • IBM i PTF Guide, Volume 27, Numbers 31 And 32

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