Wednesday, October 26, 2016

Using Null indicators with program's variables

nullind allows in null in rpg variables and fields

Null is a concept that RPG programmers are going to have to learn. Generations of RPG programmers have used a blank or zero in a variable to denote that it is not used or its value is not given. Null, in the simplest terms, means nothing, and if there is not a value for variable then null would be the ideal value to give it. If I had used a blank instead how am I to know, later, if blank is a valid value or is it being used to denote there is no value?

While null values can be found DDS files and SQL tables, it was not until IBM i 7.3 that I could code variables within my RPG programs that could be null.

Thursday, October 20, 2016

Creating User Defined Functions using only SQL

creating trigger in sql

In my previous post, Creating User Defined Functions to make my SQL statements easier, I gave example of how to create SQL User Defined Functions, UDF, using RPG. In this post I am going to show how I can create an UDF made up entirely of SQL.

I have created this UDF to concatenate the parts of the employee's name together. My example Employee Master file, EMPMST, has the following fields:

     A          R EMPMSTR
     A            LASTNME       30A
     A            FIRSTNME      20A
     A            MIDINITL       1A

When I look in the file I see:

Wednesday, October 19, 2016

Creating User Defined Functions to make my SQL statements easier

sql create function using rpg

The old ERP application I have to work with holds the "dates" in its files as seven long packed numeric fields, called *CYMD format. When I extract data from these files using SQL I always want to convert these "dates" to real dates, which I can the use for calculations, etc. I am tired of using the following SQL code to convert these fields to dates:


And if the value in the numeric field is not compatible with a date the Select statement fails, and I have to fix the data with a best guess, and try again. It would just be so much easier if I could make the equivalent of a subprocedure to do this for me, then all I would have to do is call the "subprocedure" with the value to convert and it would return a valid date.

Wednesday, October 12, 2016

Scan has a new parameter and a new BiF

changes to %scan and new %scanr bif

While it was not part of the fanfare for the release of IBM i 7.3, there were some enhancements made to RPG. Two of the changes were made to the Scan built in function (BiF):

  1. Addition of a fourth parameter to the BiF for the length of the string to scan.
  2. A new BiF Scan reverse, which the name suggests starts the scan at the end of the variable and moves towards the start.

Let me jump straight into my code example so I can explain what differences these additions make. First I need the definitions for my example program:

Tuesday, October 11, 2016

IBM i 7.3 TR 1 and 7.2 TR5 announced

IBM i 7.3 TR1 and IBM i 7.2 TR5 announced

(Updated Tuesday October 11 at 6:00 AM)

Technical Updates for IBM i 7.3, TR1, and 7.2, TR5, have just been announced on IBM’s developerWorks and Software announcement web sites.

There is lots of additions and enhancement to SQL, including a new JSON_TABLE table function that is causing quite a buzz on social media.

Even RPG has a new addition, the operation code ON-EXIT. This will force a section of code to run when something unexpected happen. There is no easy link to find it in the Software announcement pages, you will have to use your browser’s search function and search for "ON-EXIT".

Both of the updates will be available on Friday November 11, 2016.

You can learn more from these links:

Monday, October 10, 2016

IBM i Southampton – UK’s newest user group

IBM i southampton is the newest user group

Long time readers of this site know my position on User Groups, I love them. I was excited to hear that a new one is holding its inaugural meeting this week.

IBM i Southampton will be holding its first meeting on Thursday, in the city of the same name, Southampton, in the south of the UK. When I learned of this I contacted Liam Allan, who has been working to get this started, to learn more. Liam is someone I am sure we will all be hearing a lot from in the future. This young fellow is a pioneer in working with open source languages and utilities, and with the IBM i. He is a Common Education Foundation winner. And you might have seen him one of one the events he has spoken at in the USA, UK, and Sweden.

I took the opportunity to ask him a few questions on his goals for the new group.

Wednesday, October 5, 2016

Looking back into the past of your data with Temporal Tables

system temporal tables

It was during a COMMON presentation discussing the new features of IBM i 7.3 that Steve Will, chief architect of this operating system, mentioned the reason for this release was to accommodate the new Temporal tables. These new tables promise ability to see data within SQL DDL tables as it was in the past. In fact multiple users could use the same table at the same time and see the data as it was at different times, all while the table still be updated with new data.

Have been involved in projects to recreate a "snap shot" of data for a file as it was at a specific time, I can say that it is a lengthy process to roll back changes using data from journals or trigger output files. After those projects I welcome the usefulness of Temporal tables.