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!

My new favourite beer: Hercule Stout

Hercule Stout In my younger days my usual beer was stout. Guinness by default but I always preferred Murphy’s when I could find it. While I have retained a preference for darker beers, living in Belgium has led to my current tendency to go for Abbey and Trappist Dubbels. On Saturday, however, I discovered that Belgian stout is a thing.

While stocking up, I saw a crate of Hercule Stout sitting in the drink shop demanding that I pick it up. So pick it up I did and I took it home and (later) opened a bottle. It’s fantastic.

Hercule Stout is dark, creamy, smooth and everything I want from this type of beer. I will certainly be going back for more.

flattr this!

Sunday morning movie: Renegade!

Renegade has lost everything… all he has left is his Renegade underwear. Embarking on a quest to claim back what is rightfully his, he battles through dangerous lands to win back his wife from the evil Dr. Monocle.

Inspired by He-man, Harrison Ford, Paul Newman, 80′s Action figures and the childish desire to run around in your underwear pretending to be a superhero…welcome to the universe of Renegade. The story of a man who loses everything – his wife… erm, his clothes! Michael Cavanaugh & Kevin Van Witt’s short blends B-movie stereotypes, American Pulp Comic imagery and a bucket load of influences into a 4-minute narrative of riotous action.

From Short of the Week via io9.

flattr this!

Living it

Further to my earlier post, Luke makes a good point:

One thing I did notice is I am a lot less likely to be verbal about my beliefs or how I think life should be lived but am a lot more likely to act on those beliefs than I was when I was younger. Infact in the my 20s it was probably the opposite in that I’d have blathered on about what I believed but probably not acted in the corresponding way.

I think there is a lot of truth in this and, inevitably, it takes someone else to cut through my own verbiage. And maybe this is what it means to be middle-aged: being comfortable enough with my life that I am able to invest my time in living my values rather than wasting energy trying to push them onto others.

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!

Circles of influence

Mcnalu recently mused on the state of his eyebrows and the fact trimming may now be appropriate. My first thought was how lucky he is to have been asked. My own eyebrows are clearly enough of a mess that my barber doesn’t feel need to ask before trimming – this can be quite unnerving when I realise that his attention is mainly on the televised cycling.

As fascinating as my eyebrows are though, the part of Mcnalu’s post that really interested me was this:

Perhaps I’m having a mid-life crisis, but I prefer to think of it as an experience in mid-life neuroplasticity? I feel a stronger urge to express myself and make some impact, however small (though preferably large), on society around me. Being passive isn’t an option. I want to do something for others, and give them the chance to do better, and be better than me. Making myself heard is important now – it wasn’t before.

It’s interesting because, for me, the opposite is true. In my younger days it was hugely important to me that my voice was heard, that I was making a difference and leaving my mark. Now, not so much.

While I can still be quite idealistic at times, I should probably admit that this has been tempered over time by changing priorities. But I think the more significant factor in this is a greater acceptance of the limits of my influence.

To change the world you first need to join a movement and I’m not a joiner. I can’t bring myself to toe a party line, slogans annoy me and the tribalism upon which many movements depend tends to strike me as being both lazy and destructive. And if my need to remain intellectually honest with myself outweighs my desire to sign up to a consensus then I have to accept that any difference I can make is equally constrained.

Ultimately, the only person on who I can guarantee an effect is on myself. Hopefully, by living honestly and by making time for the people that matter most to me I can have a positive effect on the lives of those people. Realistically, after a couple of generations I will be forgotten.

And I am completely comfortable with this.

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!