Wednesday, September 4, 2024

Extra columns in a Select statement but not in the group by

I struggled with the title of this post to make it something that explains the content, without it being too long. I am not limited for length in the body of this post so I can explain in more detail my scenario: I want to have columns that are listed in my results for a Select statement that are not in the GROUP BY clause.

This is something that has been made easier with a new Scalar function added in the latest round of Technology Refreshes. First let me give you examples of my scenario.

What I am going to do is to take use my PERSON DDL Table and make a count of the places of birth of the people. As these are people from the British Isles, I will also include the columns for the county and the country (England, Ireland, Northern Ireland, Scotland, or Wales) from a second Table, TOWN.

Monday, September 2, 2024

September's presentations

This month I have two events I am involved with.


The September meeting of the Central Texas IBM i User Group, CTXiUG, is on Tuesday September 10 starting at 6:30 PM (CT). The guest speaker is Jasmine Kaczmarek who will be sharing "IBM i Manager's Survival Guide: Ransomware, Retirement Cliffs and more". Which is something I think we all need to be aware of, not just those of us who are managers.

You can register at the CTXiUG website here.


On Monday September 23 and Tuesday September 24 I will be attending and presenting at Common Sweden's annual conference. You can learn more about, and register, for the conference here.

I hope to see you there. And if you are attending and you see me, please introduce yourself and say "HallÄ".

Wednesday, August 28, 2024

Retrieving Printer File information using SQL

This is one of the additions that came as part of last round of Technology Refreshes that I was excited about. Previously If I need to get information about printer files I would either have to use an API or the DSPFD command. Now I have an easy way to get information about any printer file using a SQL View.

The new SQL View is called PRINTER_FILE_INFO and is found in the SYSTOOLS library.

I always recommend that you run the run the SQL statement to see all of the columns in the SQL View for yourself. That way you can make your determination which columns you find useful to your situation. You can do that with the following statement. I have a limit of returning ten results as I found that if you want to return all the results from the View it may take some time to do so.

Wednesday, August 21, 2024

Using SQL to create, update, and get from Environmental Variables

Within the latest database PTFs that came as part of the last Technology Refresh were a couple of new Scalar functions that can be used to do things with Environmental Variables. They are named after the APIs that can be used to put and get information from the Environmental Variables. These new SQL Scalar functions are:

  • PUTENV:  Creates or changes the Environmental Variable. Equivalent of the following commands: ADDENVVAR and CHGENVVAR, and the putenv API
  • GETENV:  Retrieves the value from the Environmental Variable. Equivalent of the getenv API

Tuesday, August 20, 2024

Using file name from data area for reading IFS file

The idea of this post came from a question I was asked. The questioner had a scenario where the name of an IFS file they needed read is in a data structure. They were unable to work out how to use the value from the data structure as the path name to read of the IFS file.

Let me start using ACS's "Run SQL Scripts", RSS, tool.

Before I can read a file in the IFS I need to create it. I can use the IFS_WRITE SQL procedure to do so:

01  CALL QSYS2.IFS_WRITE('/home/MyDirectory/test.txt',
02                       'First line',           
03                       END_OF_LINE => 'CRLF')

Wednesday, August 14, 2024

Finding logical files that exist in a different library to the physical

I am sure I am not the only person who wants any logical files in the same library as the physical file they are created over. I do realize that join logical files and SQL views can be built over files in different libraries, and they have always been handled in a case-by-case basis.

My senior System Administrator stumbled across a number of logical files which were in a different to their physical files, and wondered how many more there may be?

SQL to rescue and with a simple SQL statement I can give her that information.

Let me explain the scenario I will be using in these examples. I have a physical file, TESTFILE that exists in the library MYLIB. I built three logical files over it, each one was in a different library:

  1. Logical file: TESTFILE1 in the library MYLIB
  2. TESTFILE1 in the library QTEMP
  3. TESTFILE1 in the library MYLIB2

I can display the database relationship between the physical file and these objects by using the Display Database Relations command, DSPDBR:

Tuesday, August 13, 2024

Updates to the SYSDISKSTAT View and Table Functions

I have been remiss in writing about the updates in the past few Technology Refreshes to the SYSDISKSTAT View and Table function. Both the View and Table function return information regarding the spinning disk and solid-state drives, SSD, on your partition(s). While, IMHO, they can be used for different purposes, they do contain the same columns.

The columns I have identified that have been added since my previous post are:

  • HARDWARE_STATUS:  The status of the "disk" unit. There are many different statuses, refer to the link at the bottom of this post to the IBM Documentation for what they all are
  • IS_ZERO:  Returns whether all the pages on the disk unit are zero
  • HOST_WWPN:  Hexadecimal decimal string to represent the resource's host world wide port name
  • REMOTE_WWPN:  Hexadecimal decimal string to represent the resource's remote world wide port name
  • UNIT_NVME:  Whether this is a NVMe unit. 1 = It is, 0 = It is not

Friday, August 9, 2024

New version of ACS, 1.1.9.6, out now

I need to thank Shaker Steven again for bringing to my attention that a new version of IBM's Access Client Solutions, ACS, is now available.

When I opened ACS this morning the following window popped up informing me of there was a new release available:

You can either install the new version, 1.1.9.6, by clicking on the "Download Update…" button on the window displayed above. Or you can go IBM's ACS website, http://ibm.biz/IBMi_ACS (the URL is case sensitive), and download it from the website.

The instructions have not changed since I described them for ACS release 1.1.9.3.

You want to download the file that is top of the list:

Wednesday, August 7, 2024

Deleting objects in the IFS with a SQL scalar function

This post is a two-for-one where I will explain how two of the additions that came in the latest Technology Refreshes go together.

The first is a new scalar function IFS_UNLINK, which is found in the SYSTOOLS library, that deletes IFS objects that are passed to it as a parameter. Behind the scenes it calls the unlink() C API. The scalar function returns the integer value that is returned by the C API. If it completed successfully, IFS_UNLINK returns a value of zero. If there was an error the scalar function returns an errno value.

The second addition, ERRNO_INFO, which is also found in the SYSTOOLS library, is a Table function that will return the description of the errno passed to it.

The easiest way I know to be able to show you how it works is to show an example of using it.

Wednesday, July 31, 2024

Comparing differences between objects in two IFS directories

While it has been possible to compare the contents of two directories in the IFS it has not been, well, simple. A new addition to Db2 for i, SQL, in the latest round of Technology Refreshes, IBM i 7.5 TR4 and IBM i 7.4 TR10. Makes it a whole lot, well, easier.

The new SQL Table function, COMPARE_IFS uses the output from the Table functions IFS_OBJECT_STATISTICS and IFS_OBJECT_PRIVILEGES to compare the objects in two IFS directories to one another. It will only check the following object types:

  • Character special files, *CHRSF
  • Directories, *DIR
  • Name pipes, *FIFO
  • Local sockets, *SOCKET
  • Stream files, *STMF
  • Symbolic links, *SYMLNK

I created two subfolders within my home directory, /home/MyDir, called subdir1 and subdir2. I uploaded some files into each one. Some were the same files, others were different files, and some files had the same names but different contents.