Category Archives: Technology

Adding variables to ad-hoc SQL queries with REXX

It’s incredible how easily I can be distracted. All I needed was a quick and dirty way of capturing the input into an interface and now I’m writing a blog post.

Everything starts with an issue and, in this case, the issue is with an interface not behaving as expected in production even though everything works as expected in the test environment. My suspicion is that the incoming data is not correctly formatted, causing transactions to not meet the selection criteria. But to confirm this, I need to see exactly what is waiting to be processed when the interface runs.

Since this interface runs after the end of business I want to be able to submit an SQL query to capture the input data into a separate table so that I can see what was processed when I come in tomorrow morning. And, because much of this data is not destined to pass through the interface in question (this is why we have selection criteria) I want to be able to select today’s transactions for whatever the current value of today happens to be.

In a sane world, this would be a simple case of using the current date but in the real world there are still people using eight digit numbers to represent the date. This leads to some unwieldy date calculations in SQL which led me to wondering whether I could capture this in a variable to make things a bit more readable. It turns out I can, but not on the version of the IBM i operating system that I am currently using.

What really caught my eye at the above link however, was this:

but if “ad hoc sql + variables” is the thing you need, you should really try Rexx.

And I thought: “Rexx. That’s something I haven’t used since last century.”

Any excuse to download a couple of manuals is reasonable as far as I’m concerned, so off I went.

And here’s the script (library and table names have been changed):

datenow = DATE('S')
statement = 'insert into MYLIB/INPUTDATA' ,
            'select * from PRODLIB/INPUTDATA where dhdate =' datenow
address 'EXECSQL'
EXECSQL 'SET OPTION COMMIT = *NONE, NAMING = *SYS'
EXECSQL 'delete from MYLIB/INPUTDATA'
EXECSQL statement

The DATE function returns the current date and the 'S' option handily reformats it into an eight digit number (yyyymmdd). The address 'EXECSQL' statement handily points the subsequent commands to the SQL command environment and then it’s just a case of executing the statements I need to execute.

It all works very nicely indeed.

On a tangential note, I noticed that Rexx is also available in Arch. I may well install this sometime soon just to have a play around with the language.

flattr this!

The world’s heaviest metal

compressorhead logo

No-one is more metal than Compressorhead

Stickboy (drums) was created to exacting specifications. 4 arms, 2 legs, 1 head, no brain. he plays a Pearl 14 piece kit with double kick. stickboy junior, the bastard child of an unknown mother takes control of the hihat shuffle. inception date 2007

Fingers (guitar) joined stickboy in 2009 and brings 78 purpose built fingers, enough to play the entire fret board and pluck.
Bones (bass) is the highest precision bass player in known existence, and the youngest member of the band. inception date 2012.

Stand aside meatbags. Oil is thicker than blood.

Via io9, who have found a whole lot more.

flattr this!

If People Were Like Social Networking Sites

Tangential to yesterday’s post

From The Joy of Tech via Re/Code.

flattr this!

Ello, it’s another silo

Another week, another proprietary social network. This time it’s Ello which is trying to position itself as an ad-free answer to Facebook. The Register took it for a spin and made the following point in conclusion:

But is Ello quite as pure as it makes out? And will its lofty goals stand up against the test of time? I have my doubts.

Ello already has venture capital funding and VCs aren’t charities – they expect a return on investment. The site promises that its pay-for-features model will involve “very small” amounts of money but it’s going to take a serious amount of cash to run the servers needed to power the site properly if it gets a serious amount of users.

And this is why I won’t be signing up to Ello. For all its talk, Ello is yet another proprietary silo of a social network. The people behind Ello will, inevitably, come under pressure to provide a return to the venture capitalists that are funding it. It will either collapse or have to start breaking promises – quite possibly both.

And when Ello fails, all of its users will find themselves stuck in a silo again. Either they leave and lose contact with their connections, or they stay and put up with corporate behaviour with which they are increasingly uncomfortable (Hello, Facebook).

It’s for this reason that I think federated services are a much better proposition for all.

My preference is for GNU Social (also referred to as StatusNet) although other federated networks do exist (Friendica, Pump.io and Diaspora all spring to mind). The advantage that all of these offer is that you are not tied to a single provider. If I decide that I am not happy with my current instance, I can easily move to an alternative (or even install my own instance) and continue talking to exactly the same people over exactly the same interface.

We don’t accept proprietary limitations on which websites we visit. We don’t accept proprietary limitations on who we can exchange emails with. Why should we treat social networks any differently?

flattr this!

Searching multiple files in PowerShell

Today I needed to check several scripts to see which ones used (the same) global field (don’t ask). I was doing this at work and Powershell proved to be surprisingly adept at doing this. All I needed was:

Get-ChildItem "Scripts_Folder" -recurse | Select-String -pattern "Field_Name" | group path | select name

… where Scripts_Folder is the folder containg the scripts and Field_Name is the field I was searching for.

Powershell returned a simple list of all of the files containing the field. I can see me needing to use this again, which is why I’m making a note of it here.

flattr this!

IBM i Access Client Solutions… on Arch

This is a follow up to my earlier post about connecting to a cloudy AS/400 (yes, an actual AS/400 running V5R3M0).

As I mentioned at the time, I had run into problems installing iSeries Access because IBM had removed the RPMs from their site, I asked about this and the package maintainer very helpfully provided me with a collection of links to the various versions. However, he also mentioned that the source files were removed from the IBM website because they want everyone to use the IBM i Access Client Solutions. This is in the AUR as iacs, so I thought I’d try this first.

It works… beautifully.

And I do love a snappy application name.

flattr this!

Cloud/400

I never thought I would be able to use that as a post title but, as reported by The Register, German hosting company Rechenzentrum Kreuznach has popped an AS/400 into the cloud, and anyone can use it for free. I’m anyone so I signed up.

Of course, there isn’t much point in having an account if I don’t have a terminal. Fortunately, Arch has everything.

I first tried tn5250 which proved to be a nice little package that can be started from the terminal. It certainly works and achieves exactly what it attempts. The only problems I encountered were that some of the key mappings were a bit odd (probably as a result of me using the wrong character map) and (more seriously) that running one terminal inside another can cause a little command key confusion.

It was at this point that I noticed that the AUR actually includes iSeries Access. Unfortunately, this is proving to be a bit of a struggle – the package maintainer appears to have assumed that I’ve already downloaded the RPM, which I have been unable to find. I’ve left a comment on the package asking about this and will come back to it if I am able to find the RPM somewhere… anywhere.

(Tangentially: How does IBM manage to continually build such awful websites? Every time I have to negotiate Big Blue’s labyrinthine online presence, I find myself faced with sites that are slow, clunky, painful to navigate and – all too often – completely inconsistent.)

So I turned to the TN5250 Java Edition. Installing and configuring this turned out to be a completely painless process, and I’m in.

To tell the truth, I’m not sure what – if anything – I will do with this. But it’s always fun to poke around an older bit of kit, if only to remind myself how far things have progressed over the past decade.

flattr this!

Spellchecking in Vim

Here’s something I didn’t know.

I have used Vim to write text files in the past and, when I do so, I use aspell check to catch my multitude of typing errors. It turns out that Vim is also able to support spell checking, so I no longer need to keep dropping back to the command line.

Joe ‘Zonker’ Brockmeier goes into detail, but I am reposting the highlights here so that I can easily find them again.

:setlocal spell spelllang=en_gb turns on the spell checker.
:set nospell turns it off again.

]s and [s moves to the next and previous spelling errors respectively.
z= brings up a list of alternatives for the typo under the cursor.
zg adds the word to the dictionary.
zw allows you to mark a word as incorrect.

This post was entirely written in Vim.

flattr this!

Firefox 31 and the New Tab tab

Firefox 31 hit the Arch repos at some point today and now I have it. Since Mozilla moved to their 42 day release cycle, most of the changes from one release to the next have been incremental and not really worth noting. But I did notice something new when I opened a new tab.

That search bar immediately above my most recently used tabs is new. And handy.

And, for the borg-averse, you can change your default search engine by clicking on the logo. This gives you a drop-down showing your currently installed search engines and an option to manage the same.

flattr this!

Doudou Linux

Back in December, I acquired an old, old laptop with the intention of letting the twins use it. My eldest already has access to a laptop, which is running openSUSE and configured so that he is able to use it without (usually) needing any help from me. For the twins, though, I thought it would be worth giving Doudou Linux a try.

I have been very impressed indeed.

Doudou Linux is a Debian based-distribution aimed at 2 to 12 year olds. It achieves this by way of a heavily customised LXDE desktop which is very easy for a four-year-old to navigate. The terminal, and some of the settings, are tucked away somewhat – to the extent that I had to go to the online documentation in order to find them – but this makes sense in the context of a distribution aimed at young children. You really do not want a typical pre-schooler to find their way into any of the
settings, ever.

We have been using the live CD version for the past six months, but this weekend I finally found the time to actually install it. The installer is graphical, intuitive and familiar to anyone who has ever installed a Debian based distribution. The only quirk is that there is no icon – we’re back to keeping dangerous options away from little hands again – and you have to find the terminal in order to launch the installer.

The install itself is quick and painless and the laptop really is flying now. This is a very undemanding distro in terms of resource requirements:

To make DoudouLinux run, a PC or Macintosh computer with 256 MB of memory and an 800 MHz processor inside is required.

I have also been pleasantly surprised at the width of the software selection. The Childsplay and Gcompris suites are both included, as is Tux Paint. What has proved popular with the twins is Pysycache, which mainly aims to teach mouse control but comes with a collection of digital jigsaws that are surprisingly entertaining.

Also popular in our household is Raincat, a puzzle game in which you have to keep a cat dry as it travels from start to finish. The controls on this one can be a bit unforgiving and I have found that it works best if I sit with the twins, talk about how to solve the puzzle, and then handle the actions for them.

There are many more games and applications included and one of the many nice touches is that Doudou Linux groups these into age-appropriate categories (an initial menu, Mini Doudou Linux and Whole Doudou Linux) which means that the children can explore what’s available without being overwhelmed by inappropriate choices.

Overall, Doudou is a really well thought out, very nicely designed distribution that does look like it will grow with its target users. I can see us keeping this distro around for many years to come.

flattr this!