Eastern

I very much like Carnaval. But since the date of this varies per year because it is related to Eastern, I was looking for a way calculate it. And I found it. Below you see the formulas for Excel:

Copy the fomulas below where “B40″ must be in A40  so that the formula after the vertical bar comes in B40.
Separator is vertical bar “|”; list separator  is the semicolon “;”.

Then enter a year like 2001 in cel  A1 and … voilá, Eastern is in B51.

B40|=INT(A1/100)
B41|=A1 - 19*INT(A1/19)
B42|=INT((B40-17)/25)
B43|=B40 - INT(B40/4) - INT((B40-B42)/3) + 19*B41 + 15
B44|=B43-30*INT(B43/30)
B45|=B44-INT(B44/28)*(1-INT(B44/28)*INT(29/(B44+1))) * INT((21-B41)/11)
B46|=A1 + INT(A1/4)+B45+2-B40+INT(B40/4)
B47|=B46 - 7*INT(B46/7)
B48|=B45-B47
B49|=3 + INT((B48+40)/44)
B50|=B48+28-31*INT(B49/4)
B51|=DATE(A1;B49;B50)|Eastern

(Algoritm published in Nature, 1876 April 20, vol. 13, p. 487.)

 

Regular Expression to find Regular Expression

For a function in the Oracle database application I work on, we had to identify rows where a certain column contained an Oracle regular expression. Oracle supports regular expressions since version 10. There is the REGEXP_LIKE condition, but also the REGEXP_* functions like REGEXP_SUBSTR.

For our problem we had to dig a little deeper into the documentation, because we would have to escape the regular expression characters in order to find if the haystack contained a regular expression.

I came up with the next code, which seems to serve very well.

select haystack
    ,sign(regexp_instr(haystack,'[]\$^*+?{}.,()|:=[-]',1,1,0,'i')) as is_regexp_yn
from testdata;

Strange thing here is we did not have to escape the special characters! The Oracle regular expression engine seems to understand what we want. Special though in this regular expression “[]\$^*+?{}.,()|:=[-]“ are te location of the square close bracket “]” and the hyphen “-”. Better not fiddle too much with it the sequence or you’ll break it…

Where to put the comma?

I spend most of my work programming Oracle SQL and PL/SQL. Ofcourse much time is consumed by maintaining existing code. Here it is essential the code is readable and many times I start with reformatting the code. Put it in a format that I like. This refactoring also helps me in understanding the code, it’s structure. So the reformatting is not wasted time. On the contrary!

But many times I note that my preferences differ from most(?) tools or programmers. For instance the immense important question ;-) :  Where to put the comma?

I find the comma should always be at the beginning of a line and not at the end of the prior line.

Why? Simple! Just ask yourself the question: to what part of the code does the comma belong to? It is a character that indicates the next part is separated from the prior part. If there would be no next part, then there would also be no  comma!

If you would have to add a parameter value to a list, you only have to insert a new line, start with the comma and code the value. Would you have your comma’s at the end of lines, you would have to go to the end of the line, code the comma, insert a new line and only then code the value.

The “comma-at-the-end” style also has the disadvantage that when you compare two versions of a piece of code, you also get the  lines where only the comma was added; with the comma at the begin, you get only the inserted lines!

Maatschappelijk acceptabele beloning

Er wordt regelmatig melding gemaakt van leidinggevende personen die “boven de Balkenendenorm” betaald krijgen. Of het terecht is dat iemand op een bepaalde positie zoveel betaald krijgt? In 2011 is die norm 193.000 euro op jaarbasis. De exacte berekening ken ik niet en is hier ook minder relevant. Waar het mij om gaat, is dat mensen de juiste beloning krijgen voor hetgeen ze bijdragen aan onze samenleving. Of in het verleden bijgedragen hebben, als het om inactieven gaat.

Ik vind het onjuist om alleen de top te beschouwen. Soms is het nodig dat de vervulling van een bepaalde functie heel veel geld kost, omdat het een zeer bijzondere of zeer belangrijke functie is waarvoor alleen de allerbeste geschikt is. Je moet dan vaak concurreren met internationale beloningen en dan kan het nodig zijn dat daarvoor een heel hoge beloning nodig is.

In feite verdient elke functie het om passend beloond te worden. Van putjesschepper (bestaan die nog?) tot president directeur van een multi-national. Wat is maatschappelijk acceptabel? Daarbij zijn dus vele factoren van belang en het is onmogelijk om hiervoor uniforme en sluitende regels op te stellen. Beloning is ook niet alleen het geld dat men ontvangt, maar ook de andere voordeeltjes waarover men door de inzet beschikt, zoals de auto van de zaak en andere regelingen.

Ik zou het toejuichen als we stoppen met de Balkenendenorm en ons richten op maatschappelijk acceptabele beloning voor hoog tot laag.

APEX Calender report

Another powerfull item that can be used to fight the data pile: presentation by a calendar. Oracle APEX supplies us with a simple wizzard which makes it easy to present date related data.

Because I am still learning and always trying just a bit different than standard, I found something to be aware of.

Case: An application for Helpdesk Tickets (see “Beginning Oracle Application Express”). I already have the “Form on a Report” page pair which lists the tickets and links to the Ticket details update page. Now I want to create a page with a calendar where the data links to that existing details page.

Action: Create a Calendar report page and let the link of the data point to the already existing detail page.

The link being the ticket_id ofcourse. Now APEX generates a link filling the #PRIMARY_KEY_VALUE#, but it should fill the “TICKET_ID#.

Herman Mol is powered by WordPress.  Staypressed theme by Themocracy