Thursday, December 04, 2008

Oracle date goodies in SQL/PLSQL

Originally published 03/12/08...

I have been searching through Google, Yahoo! and various forums to create a small library of useful functions and crud for Oracle PL/SQL and SQL. I was either unhappy with the solutions I found or simply thought I could do them better, differently or somewhat the same.

Leap Year

(3-EXTRACT(MONTH FROM TRUNC(date_column,'YEAR')+59)) -- returns 1 if a leap year, 2 if not; from DATE datatype
(3-EXTRACT(MONTH FROM ADD_MONTHS('01-JAN-0001',numeric_year_column*12)-307)) -- returns 1 if a leap year, 2 if not; from NUMBER datatype
DECODE(EXTRACT(MONTH FROM TRUNC(date_column,'YEAR')+59),2,'True','False') -- substitute VARCHAR2 values for the result

Holidays


CREATE OR REPLACE FUNCTION is_holiday(i_date DATE) RETURN VARCHAR2 IS
v_date DATE;
v_y NUMBER;
v_q NUMBER;
BEGIN
v_date := TRUNC(i_date,'Y');
v_y := EXTRACT(YEAR FROM i_date);
v_q := TRUNC(MOD(v_y / 38 * 1440,60) / 2);
RETURN CASE i_date
WHEN v_date THEN 'New Years'
WHEN NEXT_DAY(ADD_MONTHS(v_date,1) - 1,'MON') + 14 THEN 'Presidents Day' --- Third Monday in February
WHEN NEXT_DAY(ADD_MONTHS('01-JAN-0001',v_y * 12 - 8) + v_q + (CASE WHEN v_q < 5 THEN 17 ELSE -12 END),'SAT') - 34 + (CASE v_y WHEN 2079 THEN 7 ELSE 0 END) THEN 'Easter' --- valid 1900-2199 only
WHEN NEXT_DAY(ADD_MONTHS(v_date,5) - 1,'MON') - 7 THEN 'Memorial Day' --- last Monday of May
WHEN ADD_MONTHS(v_date,6) + 3 THEN 'Independance Day'
WHEN NEXT_DAY(ADD_MONTHS(v_date,8) - 1,'MON') THEN 'Labor Day' --- first Monday in September
WHEN ADD_MONTHS(v_date,10) + 10 THEN 'Veterans Day'
WHEN NEXT_DAY(ADD_MONTHS(v_date,10) - 1,'THU') + 21 THEN 'Thanksgiving' --- fourth Thursday in November
WHEN ADD_MONTHS(v_date,11) + 24 THEN 'Christmas'
ELSE NULL
END;
END;
/
The above function appears to be fairly accurate. I tested 2000-2008 for all holidays and 1900-2199 for Easter (finding only one glitch for 2079 manually corrected with a CASE statement). The above function could prove handy if you have a time dimension in your data warehouse (who doesn't) and use PL/SQL to generate your data.

Easter



Uses the Meeus/Jones/Butcher Gregorian algorithm
FUNCTION GET_EASTER2_FN(i_year NUMBER) RETURN DATE IS
v_g PLS_INTEGER; -- the Golden number; sequence in the 19-year lunar cycle
v_c PLS_INTEGER; -- the Christian era i.e. century
v_y PLS_INTEGER; -- the year number in the Christian era
v_e PLS_INTEGER; -- the epact; days in excess of the solar year over the lunar year
v_l PLS_INTEGER; -- the ?
BEGIN
v_g := MOD(i_year,19);
v_c := TRUNC(i_year / 100);
v_y := MOD(i_year,100);
v_e := MOD((19 * v_g + v_c - TRUNC(v_c / 4) - TRUNC((v_c - TRUNC((v_c + 8) / 25) + 1) / 3) + 15),30);
v_l := MOD(32 + 2 * (MOD(v_c,4) + TRUNC(v_y / 4)) - v_e - MOD(v_y,4),7);
RETURN ADD_MONTHS('22-MAR-0001',(i_year - 1) * 12) - TRUNC((v_g + 11 * v_e + 22 * v_l) / 451) * 7 + v_e + v_l;
END;

Format Independant TO_DATE

FUNCTION TO_DATE_FN( i_datechar VARCHAR2 ) RETURN DATE IS
v_datechar VARCHAR2(32000) := UPPER(TRIM(i_datechar));
BEGIN
RETURN CASE TRANSLATE(NVL(v_datechar,'N/U/L/L'),'0123456789/-ABCDEFGJLMNOPRSTUVY','##########/-^^^^^^^^^^^^^^^^^^^')
WHEN '^/^/^/^' THEN NULL
WHEN '########' THEN TO_DATE(v_datechar,'YYYYMMDD')
WHEN '######' THEN TO_DATE(v_datechar,'MMDDYY')
WHEN '##/##/##' THEN TO_DATE(v_datechar,'MM/DD/YY')
WHEN '##/##/####' THEN TO_DATE(v_datechar,'MM/DD/YYYY')
WHEN '####-##-##' THEN TO_DATE(v_datechar,'YYYY-MM-DD')
WHEN '##-^^^-##' THEN TO_DATE(v_datechar,'DD-MON-YY')
WHEN '##-^^^-####' THEN TO_DATE(v_datechar,'DD-MON-YYYY')
ELSE TO_DATE('01-JAN-2989','DD-MON-YYYY')
END;
END TO_DATE_FN;

More to come...

Sunday, November 30, 2008

MLS 2008 Champions

Your 2008 champions of Major League Soccer: the Columbus Scruh, ... Crew.

What is more embarrassing? Having the commissioner of the league you just won a championship in come one letter short of calling you the "screw" on national television or having that same commissioner try to present the trophy to captain Guillermo Barros Schelotto when the captain was actually Frankie Hejduk; the guy strategically placed next to the cup for ease of transfer?

Suck a big one, Don.

Classic fail from the league head chimp aside, winning the 2008 MLS championship capped off a wonderful season that was a long time coming. There were a lot more fans that deserved this championship more than I. I can only offer praise to the groups that stayed with the team throughout the worst of the worst to finally get to greatness. I wasn't there for every game nor did I watch every game on television or at bar with a tab full of expensive finger foods and beer.

List of team accomplishments:

  • Took home the Trillium Cup; the league promoted distance rivalry between Columbus and Toronto, by beating them at home, then earning two draws on the road
  • Took control of the Supporter's Shield for having the best record at the end of the season
  • Defender of the Year for Chad Marshall
  • Coach of the Year for Sigi Schmid
  • Most Valuable Player for Guillermo Barros Schelotto
  • Took home the 2008 MLS Cup for defeating Kansas City on aggregate goals, the Chicago Fire 2-1 at home, and then the New York Red Bulls 3-1 in Carson City
  • MLS Cup MVP for Guillermo Barros Schelotto for directly assisting on all three goals
I made sure I picked up a copy of the Columbus Dispatch to tuck away somewhere as a memory for my later years. It would be nice to pick up a photoset, too.

Some consider the celebration short-lived. An expansion draft was held the next Thursday and starter Brad Evans went to Seattle. There is talk that defender of the year Chad Marshall is heading overseas (more cash and higher level of play) and that coach of the year, Sigi Schmid is heading to Seattle to be closer to family on the West Coast and to get a longer-term contract (three years) to make it easy to settle somewhere. A sizable chunk of cash will be required to sign Guillermo Barros Schelotto for another year or so. There are developmental players that will be waived. There will be veterans that will probably be asked to step down.

Regardless of these developments, 2008 was a triumphant year for the Columbus Crew. Nothing can take that away.

Thursday, November 20, 2008

Web 2.blow, Oracle.com version

Go to this Oracle University link with the various web browsers you have. Here is what you will see. In IE7 it renders well and you can get into the various tabs for schedules and details. In Firefox on Windows it operates but looks different. Unfortunately, it breaks on the sixth page of the checkout too but you won't know that unless you register, book a course, enter a purchase order number, enter names of five siblings you promise to sacrifice, etc. In Opera, well, it just pukes the whole mess up at the top of the screen and is totally unusable. If you set site options to mask as Netscape/Firefox it works.

Now I know I'm vastly in the minority here with Opera. That does not, however, excuse an if Netscape else if IE without an else; i.e. if the browser doesn't match anything previous just leave all objects null. Good programming would have at least put JavaScript compliant code in the final else and then hoped for the best. Most alternative browsers will try to be as standards compliant as possible.

Second, is all that JavaScript necessary? I find myself being left behind because I feel every web page doesn't need to look and perform like an iPhone. What's next; keyboards with motion sensors so. Whoops. Showing my age here. What's next; mice with horizontal and vertical sensors so... Ooops... Wrong again. Who uses mice anymore? Touch screens with voice recognition. Yeah. Every page is going to be LCD shake/touch/punch/slap and voice aware.

Actually I'm going off the deep end. I just want to be able to register for a $3,000 F'ing class so I can get a $270 certification then take another $3,000 F'ing class so I can get a $270 certification, so I can become a big-shot know-it-all Oracle guru about a month before we drop Oracle and go pure SQL Server. Now Oracle Identify Manager won't let me log into Oracle University via single sign-on (I can go to Metalink). When I "well F'you, I'll register" it says my sign-on is already in use. When I try to get my password, it says I don't exist. Sigh.

Sunday, November 16, 2008

MLS conference finals

I have some catching up to do here?

The Crew went on to defeat the Kansas City Wizards in Columbus which sent them to the finals. Chicago pounded a wounded New England three zip in Bridgeview, sending them to face us in the Eastern Conference finals. It was a match for the ages, everything it was supposed to be and then some.

There were so many back stories.

The biggest one was the return of Brian McBride. McBride was one of the original Crew players and face of the organization. To this day, people still associate McBride with Columbus. Brian left in 2003 to join English Premier League (top level) club Fulham. This season, he returned to America to end his career in the MLS but not for Columbus; he wanted to play for Chicago, his hometown (Arlington Heights). His first encounter with his former MLS team was in Chicago where he had the first and last goals of the two goal tie. Now he would make his return to Columbus with our elimination on his mind.

Another big story was the return of fan favorite Jon Busch. Jon was acquired in the 2002 SuperDraft and was starting for the Crew by 2003. Busch was between the pipes when Columbus won the Lamar Hunt U.S. Open Cup in 2002 and won goalkeeper of the year in 2004. He suffered season ending ACL injuries in both 2005 and 2006. He was waived in 2007, picked up by Toronto, then waived again and then picked up by Chicago. Busch has been, and always will be, a vocal person. The person who once stated that he could not see playing anywhere but Columbus was now displaying public anger towards Coach Sigi Schmid.

What else? The Fire had Kettering, Ohio native Chris Rolfe. Both teams played to two, two to two draws. Chicago was the only team Columbus did not defeat in 2008. The Crew lost to Chicago back in the June Open Cup match.

The first goal of the match was the worst possible scenario. Roughly 30 minutes into the game a defensive brain fart lets McBride get a head on a Mapp cross. One to zip, visitors and the travelling fans were jubilant. The Columbus fans never gave up though. The second half was a completely different story.

Roughly 50 minutes into the match, Crew central defender Chad Marshall out-duals the aerial powerhouse McBride and heads home a Guillermo Barros Schelotto free-kick. It was a perfect strike off the cross-bar; nothing anyone could have done to stop it. Five minutes later, Eddie Gaven buries a low, bouncing shot underneath Busch for the second goal. That one would end up the game winner.

About forty nervous minutes followed. I certain every single Crew fan was thinking the same thing: when was McBride going to tie this in the dying moments of regulation (just like he did in Chicago). Well, it didn’t happen. A few missed heartbeats later the Crew were going to their first MLS Cup with their first conference championship.

Massive.

The Crew will face the Western Conference champions - the New York Red Bulls??? Don't ask. Just destroy them.

Monday, November 10, 2008

Mojave part 3, Mojave fights back

The machine I have been using Mojave on has had one or more folders in the \Users folders get corrupted and rendered inaccessible. The short version of this fix was to make a copy of the most previous version of the corrupt folder, shut down, boot with the Mojave install DVD, go to recovery, get to the command prompt, then run chkdsk C: /f, then pray a bit, then see if things got fixed and if you need to recover.

What a load of warthog feces.

The pain-in-the-ass is not being able to run the chkdsk from the Mojave GUI or when the computer is restarted (via prompt when you try to run the GUI chkdsk). You can tell it over and over and over again but it never seems to run chkdsk.

Fine...

This corruption has occurred after installing software and after installing updates. Apparently, others have run into this problem.

Monday, November 03, 2008

MLS semi-finals, leg 1

The first leg of the home and away aggregate goal series went close to how I thought it would go. The Crew tied the Wizards with a late goal; so they will have to win the series at home. Wizard play maker Hercules Gomez will sit out that game because he was ejected after a violent foul in game one. New England was unable to score goals at home but luckily for them, the Fire didn’t score any either so their series is tied. The Red Bulls tied Houston on their home turf so they will probably get pounded when they travel to Houston. Real Salt Lake took a goal at home and hopefully they will survive their trip to California. Not surprising, there were three ties out of four games and not much scoring.

Mojave, part two - the revenge

I have been using Windows Mojave for over a month now so I have decided to post some more thoughts.

Wireless networking, well, networking in general, is annoying at times. Compared to Windows XP, Mojave looks like it tries to do too much to make wireless networking dumb-ass proof. I usually end up doing a reboot after switching wireless networks because when I undock (from a wired connection) the wireless connection at work picks up if I’m lucky or when I get home the connection is strong but doesn’t always connect or connects for a moment or two then disconnects. It might be Dell because I’ve never had a problem with an IBM laptop.

Most of the problems with Windows Mojave have been with non Microsoft software. Symantec has an issue with correctly going into sleep mode, causing the battery to drain completely when you least expect it. Oracle’s Developer Tools for Visual Studio do not work out of the box. Then again, if Visual Studio was a 64 bit application, things might be different. Video and audio CODEC support in 64 bit mode is provided by someone outside of Microsoft and Media Player 32-bit is the default player, not the 64-bit one.

I think what annoys me the most about Mojave is that it just isn’t necessary. I was reading a magazine in the can the other day and one guy was suggesting that businesses start adopting Mojave because people are going to be wanting widgets for the side-bar. Really? That’s why I should upgrade hardware and operating systems, because people will be wanting sidebar widgets. How about some freakin’ software that works? How about 64 bit versions of some software? It has been how many years since 64 bit on the desktop was a reality? Some programs are not Mojave capable. How hard is it to make a program Mojave compatible? Some programs only work when run as administrator; why would a semi-thin client require administrator rights to work? Stupid.

My current impression of Mojave hasn’t changed much. It is a nice looking operating system and there are some things in the start menu that I like (like how you can type in the name of a program or control panel setting and it will filter the lists immediately for you, helps when you don’t have a mouse). Then again, everything I can do for this blog, my stories, and work can be done in Windows XP on a machine with a fourth the horsepower.

Sunday, October 26, 2008

Crew vs. DC, playoff thoughts

Today's match against D.C. United couldn't have been scripted any better. The same northwest goal post that denied two United attempts happily tucked a Brad Evans long-range shot into the back of the next for the only goal of the match. The massive supporters groups were able to enjoy the Supporter's Shield trophy and the Columbus Crew sent a hated rival with a long history of knocking us out of the playoffs, out of the playoffs. How sweet it is. Now it is on to the playoffs.

The first round of the MLS semi-finals consists of a home and away aggregate goal system. The lowest seed hosts the first game and the highest seed hosts the second game. In my opinion, this does not give the advantage to the team that did the best during the regular season. At best the two teams are equal or a slight advantage is given to the lower seeded team. Here is why.

The lower seeded team can come out hard; early and usually get away with it. New England did this to us in 2004 by delivering some hard fouls early in the match to our playmakers and midfield anchors (notable was a Shalrie Joseph tackle on Simon Elliot, worthy of ejection but went without even a caution and Simon wasn't the same player after that tackle; Joseph did the same thing to Jaime Moreno when they played DC, btw).

Using home field advantage for the first game, the lower seeded team has more control over the flow of the game as the visiting (higher seeded) team must usually sit back and feel out. The home and away series somewhat turns into a two-half match (one half home and away). So if the home team can squeeze out a victory by a goal (or more) they still control the flow of the game because the second leg forces the higher seeded team to score that many goals plus one (to avoid penalty kicks). The higher seeded team will need to press for goals opening them up for counter attack goals. I think this format benefits the "boring", defensive teams that rely upon the two or three highly skilled players up top typically running a quick counter attack three on three or four.

The first round will feature Columbus vs. Kansas City and Chicago vs. New England in the east, Houston vs. New York and Chivas USA vs. Salk Lake in the west. If I were New York I'd come out full throttle for the full 90 minutes and rack up as many goals as possible on that crap Astroturf surface. I still think Houston will take that one in the long run otherwise. I would like to see Real Salt Lake get by Chivas USA just to give Jason Kreis a pat on the back for his years of service to MLS, give the fans a pat on the back for being patient and getting a new stadium, and to keep California out of the playoffs. In the east I think New England is too volatile and weakened to go up against a surging Chicago team. I also think the Crew will prevail against Kansas City but we might have to do so on home turf.

Wednesday, October 08, 2008

Why SQL generators suck

Assume the following table:

CREATE TABLE craps
( craps_id NUMBER
, crap_size NUMBER
, crap_color VARCHAR2(16)
, crap_when_taken DATE DEFAULT SYSDATE
, crap_when_flushed DATE
, crap_rating NUMBER
, CONSTRAINT craps_pk PRIMARY KEY ( craps_id )
) storage_clauses, logging_clauses, santa_clauses ....

To get a list of craps and their size and color for a time interval by time it was flushed or if that was null (i.e. it was a proud poop that someone wanted everyone to see) the time it hit the bowl; the efficient SQL would be:

SELECT crap_size
, crap_color
, NVL(crap_when_flushed,crap_when_taken) crap_flushed_taken
FROM craps
WHERE NVL(crap_when_flushed,crap_when_taken) BETWEEN :1 and :2
ORDER BY crap_flushed_taken ASC NULLS FIRST;

Oracle would do a full table scan, efficient blocked I/O, and then poop out the results. Oh, wait. We're using a canned, record-based, RDBMS independant system that generates SQL that selects a list of primary keys and then reads each record by primary key. So we have something more like this:

SELECT craps_id
FROM craps
WHERE NVL(crap_when_flushed,crap_when_taken) BETWEEN :1 and :2
ORDER BY NVL(crap_when_flushed,crap_when_taken);

and for each selected primary key value:

SELECT crap_size
, crap_color
, NVL(crap_when_flushed,crap_when_taken) crap_flushed_taken
FROM craps
WHERE craps_id = :1;

Oh, wait. That NVL on those two fields is business logic that needs separated from the data layer; so we create a function:

CREATE OR REPLACE FUNCTION 
crap_flushed_taken (i_crap_when_flushed DATE, i_crap_when_taken DATE)
RETURN DATE AS
BEGIN
RETURN NVL(i_crap_when_flushed,i_crap_when_taken);
END;

No, no, no, stupid. That layer shouldn't need to know to pass two dates in it should work off the record/object primary key identifier:

CREATE OR REPLACE FUNCTION 
crap_flushed_taken (i_craps_id NUMBER)
RETURN DATE
AS
v_crap_when_flushed DATE;
v_crap_when_taken DATE;
BEGIN
SELECT crap_when_flushed, crap_when_taken
INTO v_crap_when_flushed, v_crap_when_taken
FROM craps
WHERE craps_id = i_craps_id;
RETURN NVL(v_crap_when_flushed,v_crap_when_taken);
END;

Actually, this is how they did it

CREATE OR REPLACE FUNCTION crap_flushed_taken (i_craps_id NUMBER)
RETURN DATE
AS as language java name 'com.crap.name.name1.CrapFlushedTaken(java.lang.Integer) return java.lang.Date';

That's a Java class that basically does the exact same thing that little slice of PL/SQL was doing. The final, generated SQL statement went something along the lines of this:

SELECT craps_id
FROM (
SELECT q1.craps_id
FROM craps q1
WHERE NVL(crap_flushed_taken(q1.craps_id),TO_DATE(1,'YYYY')) >= TO_DATE('????????','YYYYMMDD')
AND NVL(crap_flushed_taken(q1.craps_id),TO_DATE(1,'YYYY')) <= TO_DATE('????????','YYYYMMDD')
) t0
LEFT JOIN craps t1 ON t0.craps_id = t1.craps_id
ORDER BY WHERE crap_flushed_taken(t1.craps_id) ASC NULLS FIRST, t1.craps_id ASC NULLS FIRST;

Then the list program read each one of the selected primary key values and did this:

SELECT crap_size
, crap_color
, crap_when_flushed
, crap_when_taken
FROM craps
WHERE craps_id = :1;

Holy slang for feces! Oracle does an index fast full scan on the ID, which it would see as the most efficient way of going about this because in the optimizer's sane mind it would never think anyone would do a single read of the same table inside of a function. So for each primary key in that table (because we don't know the result of the function so no way to limit the working set) we are doing at least three (select, order by, list program), random (record location likely won't match the maintained order of the index), entire table reads using an index (read index block, then lookup corresponding block). Poop on me and call me a sundae...

I tried to simulate the above with inline select statements but the 10g optimizer was smart enough to figure it all out and come up with a plan five times the cost of the optimized plan for proper, hand-tuned SQL. I could try running the thing to get real statistics but unfortunately this thing runs for nine hours. My efficient SQL above runs in 30 seconds.

There are options available. First would be to rewrite the canned code and do the selection process with the optimized hand-written SQL. Another option would be to create an index on the function (haven't tried it yet) so theoretically Oracle will see the SELECT crap matches an index and use the index instead of reading the whole table one row at a time through the primary key index.

I know this is probably an extreme example (or one of many) but I think the same thoughts can be applied to code generators and to the object oriented purists that believe no business logic whatsoever belongs in the data tier.

Tuesday, September 30, 2008

Mojave, whoa oh oh oh

Microsoft's new operating system, Mojave, was mandated for installation on the new hardware my employer recently purchased for me. Mojave looks an awful lot like Vista was supposed to look like but I heard Vista wasn't doing so well so I understand why Microsoft would want to replace it with Mojave. Anyways, I have decided to document my experiences here.

We installed the "Business" version of Mojave because the "Ultimate" version didn't have something that the "Business" version did have. We also installed the 64 bit version because the 32 bit version was either "a piece of crap" or "sucks donkey balls", I can't remember which. Luckily the hardware vendor provided a disk with all the appropriate drivers although we had to download a couple to get certain features to work. By installing the operating system ourselves we didn't have the 40 gigabytes of pre-loaded bull-feces to uninstall.

The second step was to install all the software we use on a daily, weekly, only-when-we-are-forced-to basis. As a systems administrator and developer I had double the amount of crap to install on the machine but was intelligent enough to download it all ahead of time to a portable drive. There was a lot of "Cancel or Allow" and "Something is attempting to do something" which led to a lot of clicking without reading because after a while you just get numb to it all. I could have been installing some Nazi Al Qaeda kitten snuff porn server hub and not known it because I had become conditioned to clicking these authorizations all the time. The only piece of software that isn't working at this writing is Eclipse. It throws a Java error when it starts up. Fudge.

The first noticeable difference between Mojave and XP is the Windows Sidebar. The sidebar, which by default hovers just above the clock in the explorer bar, features another clock, mini slide-show and news ticker. These things are called gadgets and there are about 400 more of them available ranging from just crap to useful eye-candy. Not wanting to be un-cool, I've loaded as many gadgets as I could into the sidebar. I don't need them but they look snazzy so who cares. I can't wait to have a themed slideshow so I can have some microscopic nudity in the sidebar for when I'm home.

Mojave includes a lot of eye-candy; i.e. things that look really sharp but might not affect your productivity.

I have found a few annoyances. The defragmenter does not show status, it just says this might take minutes or hours. To get around this run the command prompt as administrator then do a "defrag c: -a –v" to defragment drive "C:". I could not figure out how to enable hibernation (I have to create a power plan or something and still couldn't find the option to enable it) so I have to use "sleep" mode or shut down. The initial working set (i.e. just the applications that load at startup) is 1.4 GB. The machine has 4 GB so I will not pass judgment on Mojave being inefficient without looking at the internals. See my other blog posts on memory consumption; i.e. I'd rather have the machine using memory than hitting disk.

I am certain there will be more things to report as I use Mojave but at this time I'm not impressed. Everything I can do on Mojave I can do on Windows XP and even Linux if I so chose.

Thursday, August 28, 2008

ORA-01008 on PL/SQL MERGE over link

If you get an "ORA-01008: not all variables bound" error when trying to do a MERGE INTO a remote table using local PL/SQL variables and local data from local tables, what do you do besides beat your head against the wall until it is soft and mushy like a sponge?
DECLARE
v_turd VARCHAR2 := 'Stinky';
BEGIN
MERGE INTO table@link m
USING (
SELECT
crap
, poop
, dood
, loaf
FROM local_table
WHERE num = 2
) u
ON (m.loaf = u.loaf)
WHEN MATCHED THEN UPDATE SET m.turd = v_turd, m.poop = u.poop
WHEN NOT MATCHED THEN INSERT VALUES (u.load, v_turd, u.crap, u.poop, u.dood, u.loaf);
COMMIT;
END;
Thankfully, it only took a couple of Google searches to find a solution offered by Carsten Herbe at Oracle's forums. The INSERT and UPDATE statements in the MERGE must only use data defined in the USING or literals (or maybe other stuff too). So...
DECLARE
v_turd VARCHAR2 := 'Stinky';
BEGIN
MERGE INTO table@link m
USING (
SELECT
crap
, poop
, dood
, loaf
, v_turd turd
FROM local_table
WHERE num = 2
) u
ON (m.loaf = u.loaf)
WHEN MATCHED THEN UPDATE SET m.turd = u.turd, m.poop = u.poop
WHEN NOT MATCHED THEN INSERT VALUES (u.load, u.turd, u.crap, u.poop, u.dood, u.loaf);
COMMIT;
END;
Sometimes I feel sorry for us computer nerds that have to deal with frustrating little things like a damned ORA-01008 that works perfectly in SQL when you are testing but as soon as you try to automate it with a variable you get your geek pee-pee whacked with a ruler. Bad geek, no work. Thankfully the clicker-web is littered with other suffering nerd-souls that have run into these problems on the smallest of free systems to multi-million dollar goliaths. Unlike other nagging problems this one didn't cause much suffering on my part. Hopefully by posting this here it will add to the Internet litter and maybe help others faster.

Tuesday, August 26, 2008

Oracle instant client, Ubuntu, revisited

For those that want quick installation instructions assuming you have the installation files on the root of a mounted CDROM:

sudo -s
mkdir /opt/oracle
cd /opt/oracle
unzip /media/cdrom/instanclient-basic- (etc.version.blah.blah)
unzip /media/cdrom/instanclient-sdk- (etc.version.blah.blah)
unzip /media/cdrom/instanclient-sqlplus- (etc.version.blah.blah) optional
ln -s instantclient_11_1 client
cd client
ln -s libclntsh.so.11.1 libclntsh.so
ln -s libocci.so.11.1 libocci.so
ln -s libsqora.so.11.1 libsqora.so
tr -d '\r' < /media/cdrom/tnsnames.ora > /etc/tnsnames.ora
tr -d '\r' < /media/cdrom/sqlnet.ora > /etc/sqlnet.ora

To use SQLplus from a shell you need to add the ORACLE_HOME=/opt/oracle variable and add /opt/oracle/client to variable LD_LIBRARY_PATH to the /etc/bash.bashrc (for example).

Tuesday, July 15, 2008

Making fudged PII

As I start dealing more with application development that sends data to external sources I think more about the security of personally identifiable data within that data. When testing web services and file transfers there is no reason to have real, personally identifiable information (PII) in that stream of test data. However, the destination for that data still needs values in those elements. There are a few ways to approach this:

  1. Random data
  2. Pre-generated test data, test cases, etc.
  3. Use existing data but generate PII from a real primary key


The main problem I see with randomly generated data is "re-testing". For example: you send data for ID 1234567 to a service, randomly generating four columns of test data, then that service requests a re-test with the same data.

Pre-generated data would be a set of test cases, known trouble patterns and other data created before testing occurs. This scenario is feasible for new development on new data systems, to test min/max/null value scenarios that would otherwise never appear in live data, or to force a specific set of data. Where this scenario becomes cumbersome is when there is a tightly integrated system with numerous historical pre-cursor processes; triple the complexity if that system is another vendor's package and not your own. For example: create customer, purchase 14 months worth of product, run through aging and re-bill process, reconcile A/R, and then skip a month of purchases. There could be over a hundred tables touched by that set of processes and if one is skipped/missed then the data for another group is no longer valid.

Generating test data from the primary key is feasible when the system has a long history of identified test data handy but simply needs PII altered to protect the identity of the individual or organization. By using a unique, primary key the "fudged" PII data will always match back to the source primary key for instances where "re-testing" is required. For example: ID 1234567 always generates social security number 898-75-5309 (not a real number but will validate in some systems).

The example below was written for Oracle SQL to show how to convert a seven digit primary key identifier into a social security number, date of birth and gender:
SELECT t1.id  --- VARCHAR2(7)
, TO_CHAR(899-FLOOR(TO_NUMBER(t1.id)/989901),'000')
||TO_CHAR(MOD(FLOOR(TO_NUMBER(t1.id)/9999),99)-99,'S00')
||TO_CHAR(MOD(TO_NUMBER(t1.id),9999)-9999,'S0000') social_security_number
, TO_CHAR(TRUNC(TRUNC(SYSDATE-6574.5,'YEAR')-MOD(FLOOR(TO_NUMBER(t1.id)/10),2191.5)-CASE SUBSTR(t1.id,-1,1)
WHEN '2' THEN 2191.5
WHEN '3' THEN 2191.5
WHEN '4' THEN 4383
WHEN '5' THEN 6574.5
WHEN '6' THEN 8766
WHEN '7' THEN 10957.5
WHEN '8' THEN 13149
WHEN '9' THEN 15340.5
ELSE 0 END),'MM/DD/YYYY') date_of_birth
, CASE
WHEN SUBSTR(t1.id,-1,1) < '5' THEN 'Male'
ELSE 'Female' END gender
, CASE SUBSTR(t1.id,-1,1)
WHEN '0' THEN 'AI' --- American Indian/Alaskan
WHEN '1' THEN 'AS' --- Asian/Pacific Islander
WHEN '2' THEN 'BL' --- Black/Non-Hispanic
WHEN '3' THEN 'HS' --- Hispanic
WHEN '4' THEN 'NR' --- Non-Resident Alien
WHEN '6' THEN 'AS'
WHEN '7' THEN 'BL'
WHEN '8' THEN 'HS'
ELSE 'WH' END ethnic_code
FROM table_name t1 WHERE [selection criteria];
The social security number is pretty straight forward. If area numbers (first three digits) higher than 772 do not validate, then use area 267 (237-267 have all groups allocated within them).

The date of birth is a little complicated but the attempt was to use the ones digit to generate one of seven date ranges with the lower two in the range getting more hits because they are the primary age group dealt with. Starting with a base age of 18 years of age, subtract one of seven six year blocks, and then subtract zero to six years.

Gender was a simple test of the ones digit to determine male or female.

Ethnic background was a simple translation of the ones digit to a code taking into account there are more numbers in four of the six groups.

This was a very bare example meant only to suggest direction. It would be interesting to build a library (although someone probably already has).

Sunday, July 13, 2008

No more Mr Cranky

One of my favorite Friday morning web reads is calling it quits soon. Mr Cranky and his movie reviews are going away in August. I’m so, well the world isn’t going to come to an end but a good source of honest movie reviews and funny caption contests will be no more. I’ve thought about writing movie reviews here and have done so for the “Blog of the Dead” but they relate directly to zombie movies and not to movies in general.

In order to write movie reviews I would actually have to go to see movies in the theater. I’ll probably go see the Dark Night but I think the last movie I went out to see was Spider Man 3 and that was only to see how badly they fucked up the Venom character. I typically wait until the movies hit the rental queue on Netflix and I’m usually limited to horror movies and whatever movies my girlfriend rents. Theoretically I could still do reviews of rentals but they would be kind of late, wouldn’t they? I could always do mini-reviews of the rentals to see if my warped mind matches the rest of the critical world but I find myself with barely enough time to write for this blog and my story blog.

Maybe instead of doing something in absence of Mr Cranky I should just let it fade off and not do something in the same vein, that would be the best honor of all.

Update: Mr Cranky did not go away. Yay!

Thursday, July 10, 2008

Web 2.blow

Okay this whole web 2.0 lets throw everything and the kitchen sink into a web browser and use it as a business computing platform has given me a reason to get angry and blog again.

I usually have two physical machines active at work (well, at home too). I have the Windows XP based machine where I do most of my work and an older Ubuntu Linux desktop machine that I use for web browsing, music listening, scripted automation, etc. I have four desktops on the Linux machine: music player and maintenance, one ore more Opera web browser sessions for various documentation and manuals, Opera web browser for Google searches, and one empty just in case I need it. This configuration is very useful to me and it comes in handy sometimes because the Windows XP machine has about 300 megabytes of anti-virus, usage monitoring, remote management agents, network client, print client, database server, remote update agents, groupware notification agents, software update sleeper programs, and who the frak knows what else running on it before I launch the first bit of work. In fact, if I have to boot/reboot the Windows XP machine in the morning I can usually have the Linux machine booted with all the applications I use there loaded, my "Good Morning" Opera session loaded and all pages viewed, etc. just as the Windows XP machine finished its rituals. Occasionally, usually when I'm doing real intensive work, my employer schedules scanner software to make sure I don't have any viruses, spyware, malware, underwear, etc. and to inventory my machine for hardware and software, and to scan all directories for .avi, .mp3, .mpg, etc. to see how much hard disk real-estate I'm using for I'm assuming "non-work related" stuff.

Okay, I know, get to the point. As we use more web-based applications I keep running into more examples of where a) they don't work in a browser, b) do not have complete functionality in one or more browsers; c) have functionality (possibly) broken by a feature of a browser. Here is what I deal with:

  • one environment, since it is deeply integrated into IE6, does not work in IE7 (so we cannot upgrade to IE7 yet)
  • one application simply refuses to work in Opera but works in IE6 and Firefox
  • one application works in IE but not well in Firefox or Opera due to poor JavaScript and CSS (yes, it's a Microsoft Visual Studio project, how did you guess)
  • one application works in IE but occasionally loses functionality in Firefox and Opera
  • one application requests I upgrade from IE6 to IE7
  • one application works in IE and Opera, but not Firefox (could be fixed with a GreaseMonkey script?)
  • one application does not work in Opera because of how they implement(ed) display:none in CSS for images

There are some applications that do make sense in the Web 2.0 world. However, there are also things that are better off in a "thick" client that is forced to adhere to a strict window API/widget toolkit. People have been conditioned, for good reason, to not trust the Internet and that is the reason why all the browsers either include anti-phishing, anti-hacking, ad blocking, flash blocking, JavaScript blocking, fraud protection, content blocking, etc. via add-on or built-in. Combine that with the straight fact that CSS, JavaScript, DOM and default fonts are not the same and/or do not work the same way on IE6, IE7, Firefox, Opera, etc. and that, IMHO, is why web based applications that try to do too much, fail (and piss me off).

Oh, and don't get me started on how security and personal identity security has been handled in this new, networked and Internet world.

Monday, June 16, 2008

Lots, defined

Do you know the drill when you are ordering Lleb ocaT? You drive up to the menu and wait for someone to say something along the lines of "how are you doing?" instead of something like "welcome to Lleb ocaT can I take your order please?" I can understand if they want to shorten it to "welcome, may I take your order?" but most times when I get that fake drive-thru ice breaker I sit there after my brief "fine" answer waiting for someone to ask me what I'd want to force down. You then order your "food" and/or beverages, proceed to one of perhaps two windows, pay, get a drink shoved in your face, get your change, and then they ask "any mild or hot sauce?" as they are ready to toss the food bag at you.

I always reply "lots of hot sauce please".

Unfortunately there appear to be very few Lleb ocaT franchises that understand what "lots" means. In my opinion, there are four responses to the "sauce" question: none, some, yes (enough or adequate), or lots.

  • "None" is self explanatory. The taste of the product is adequate, you can stomach it without the need for sauce, or you have more powerful chemical additives at home.
  • "Some" indicates you need at least a couple to either enhance the flavor of the food product, toys for the kids to play with, or would feel cheated if you didn't ask for some sauce.
  • "Yes" indicates you will need at least one sauce package per food item. This would most likely be the formula agreed to by management to equally appease customers flavorfully and parent company stockholders and franchise ownership fiscally; multiplied by 1.3275 rounding up.
  • "Lots" indicate that you either need to strongly mask the flavor of the food product or are so frakkin' hungry every ounce of sauce, food product, and wrapper scrapings are required to nourish you. This realistically means at least one per taco sized item and two to four per burrito depending upon burrito size and how much refried bean food product is in the burrito.

So today I order two burritos and three soft tacos, ask for "lots" of hot sauce and I'm given a whopping four plus no napkins to clean up with afterwards. Wow. Did you spit in the food as well?

I know how food service works. There are bean counters that know exactly what volume of soft drink to push, exactly how much product to deliver, exactly how many bags you should use and how many condiment packages you should put in with the order on request. They are looking at numbers under a microscope. Somewhere someone is saying "if we reduce the sauce packages by one per order we save 22/100 th of a cent in sauce and 1 and 13/100 th of a cent in manufacturing and 8 cents in advertisement per order. If you multiply times the average of 300 orders per day the franchise and stockholders can save over ten thousand dollars per year in just hot sauce packet count reduction. Do the same for "mild" and "fire" that would be a net savings of over thirty thousand dollars. If we assume our customers are slobs and reduce the napkin output per bag we can save the franchise and stockholders another twenty thousand dollars per year. Just in the United States alone, the estimated savings is a lot of money; probably over a trillion dollars. We could knock out the national debt in three years just by shafting the customer out of a hot sauce and napkin every single day."

Wow.

I think I'll just go to S'ydnew next time.

Tuesday, June 10, 2008

Quickie update

Felt like a quick update.

Life in general

I usually try to keep my personal life out of the public only occasionally making reference to my job or home life. My personal life is just that, personal. I'm not some MySpace or YouTube attention whore that needs to pine endlessly about what Jason the boy stud did in study hall today. Things are getting better, though.

The Blog of the Dead

I am slowly attempting to catch up to the present times with my story blog. I have a large segment in December 2007 completed but need to fill in that piece with the story ending in October 2007. I usually have two or three different story pieces going at the same time depending on where I'm at when I get creative. There was one on the laptop and one on my main workstation. I use a USB drive to keep things in sync. I keep names, locations and an event timeline in an Excel spreadsheet.

Technology

Sometimes I wonder if I'm a glutton for punishment or just too stubborn to do anything differently.

I have two, high-powered machines at home: AMD X2 processors, one with 8GB of memory, one with 4GB of memory, both with infinitely more disk than they will ever need. I am installing Ubuntu 8.04 LTS server 64-bit on each of them. So why does this make me a glutton for punishment? Well, on one I am going to be installing VMWare and on the other I will be installing Oracle 10g database. VMWare is not guaranteed to work on the kernel Ubuntu 8.04 LTS server 64-bit is using and not really guaranteed to work on Ubuntu, period. Oracle 10g database is only supposed and to be used and installed on Red Hat Enterprise Linux or SUSE Linux Enterprise Server. Instead of using either of those two (they cost money, BTW), or using the free version of one (OpenSUSE), or one of the downstream distributions from Red Hat (Oracle Linux, Cent OS), I chose to use a different distribution and then scour the clicker-web looking for ways to force it to work with VMWare and Oracle database. Just by using the 64 bit version of Ubuntu is inviting pain, suffering and trouble. The X-Server 64 bit version does not work the same way as the 32 bit version on the same hardware. The 64 bit nVidia drivers are worse.

So why do I do this? Why not install Oracle database on Oracle Linux? Why not install VMWare on a kernel and distribution they support instead of searching far and wide looking for the patch and notes on how to install it?

I must be sick.

Wednesday, June 04, 2008

Chili recipes

Just creating a blog post containing tasty chili recipes I've collected. If you stumble upon this and have one then leave a comment with a recipe or URL to one.

Turkey and Chicken Chili

  • 1 lb boneless skinless chicken breast
  • 1 lb turkey sausage (breakfast)
  • 1 can chili beans
  • 1 can diced tomatoes (Del Monte "zesty chili style")
  • 1 small can tomato paste
  • 1 pkg chili seasoning
  • 1/2 red onion, diced
  • 1/2 red bell pepper
  • 2 tbsp chili powder
  • 1 tbsp salt
  • 1 tbsp pepper
  • 1 tsp crushed red pepper
  • 1 tbsp cilantro
  • 1 tsp garlic powder
Pan fry the sausage with the red onion until brown. Boil the chicken until it's tender enough to be shredded. Combine the meat in a pan and add 1 cup of water and the seasoning packet. Reduce until water is almost completely gone. Add in everything else however you want.

Can be topped with shredded cheese, sour cream and/or chives and served with cornbread on the side.

Tuesday, June 03, 2008

Worth Quoting

Dave Barry on the Economic Stimulus Payment

This year, taxpayers will receive an Economic Stimulus Payment. This is a very exciting new program that I will explain using the Q and A format:

Q. What is an Economic Stimulus Payment?
A. It is money that the federal government will send to taxpayers.

Q. Where will the government get this money?
A. From taxpayers.

Q. So the government is giving me back my own money?
A. Only a smidgen.

Q. What is the purpose of this payment?
A. The plan is that you will use the money to purchase a high-definition TV set, thus stimulating the economy.

Q. But isn't that stimulating the economies of China and Japan?
A. Shut up.

Saturday, May 24, 2008

Computer hell

Friday night was a damn crummy night for me and my computers.

The first pile of crap I had to deal with was the 64 bit server version of Ubuntu. I have a powerhouse AMD X2 machine with 8GB of memory and 900 gigabytes of disk (500, 200 and 200). This machine will be dedicated to running VMWare Server and various groups of virtual machines for developmental purposes. I had the new 8.04 LTS edition. I installed using LVM leaving extra space for expansion of logical volumes if necessary.

The first problem was GRUB wouldn’t do anything. Reboot, black screen, nothing. I altered the installation to install LILO and things worked this time. It was a minor annoyance but foreshadowed pain to come. I needed a desktop for VMWare so I decided to try KDE by installing the kubuntu-desktop package. There were four warnings issued during the installation. When I rebooted, LILO simply puked a bunch of 99’s on the screen then died. Great. I’ll try again later.

I just purchased a 24” wide screen LCD to replace the LCD one of our cats puked on and rendered non-operational. One of the problems with the large surface area of the desktop is that the styles that come with Windows XP are dull and look like crap. Some people at work have some really nice desktops so I figured I would find a nice them online, install it and bask in my coolness.

I went to a place called ThemeXP. I’m not going to provide a link, you’ll find out why later. I downloaded two themes in the form of executables. I assumed they were installers. When I tried installing them I was greeted by a pop-up window that explained these files had been “wrapped” and that you had to agree to services, etc. In short it was “f***-no” terminology.

I did some more investigation and found a link buried at the bottom that indicated some files were “wrapped” to defer operational cost through advertisements. Nice. We can really trust those advertisers. They have a stellar history of not trying to f*** over computer users. I cancel the install and look elsewhere. Then I noticed my hard drive just chattering away. Then AVG pops up a virus warning. I quickly do a process list and kill a msin.tmp process that was spawned by this “wrapper” program. More and more AVG pop-ups with files infected with the Win32/Gaelicum.A virus. My hell was just beginning.

I unplugged the network cable and booted a clean machine while scanning the infected one. The Win32/Gaelicum.A virus is a nasty little bastard that infects .exe files and is network aware. Grisoft had a cleaner utility to download and run in safe-mode. The problem, however, was that Grisoft AVG anti-virus had moved all infected executables to their virus vault; including the executable to manage the virus vault. So I can’t get the executables out of the vault to run the cleaner utility on them. Well that was just great.

I had to sleep on it. I was beyond furious.

So how did I fix it? In short: remove the infected drive from the computer and place it in a portable enclosure. Attach that drive via USB to a clean computer running the same software, copy AVG and Windows executables from the clean machine to the infected drive, copy vcleaner to the infected drive, detach the drive, install the drive back into the machine, boot, run the virus vault utility, take the infected executables out of the vault, reboot in safe mode, run vcleaner, reboot, scan again, test executables.

Whew.

Damage was minimal. Some things won’t uninstall due to corrupt binaries and I had to reinstall 7-zip.

I am a computer professional and I almost had my entire computer f***ed because I wanted a nicer looking desktop. I sent a mail message to themexp explaining what happened and haven’t heard back from them. Rot in hell. There is so much garbage out there that if you see a screen saver or theme or program somewhere just don’t install it. Don’t let your kids install screen savers or programs. If they do then punishment is no games and no Internet unless you need it for school. Don’t let you parents click on things unless you put them there to click on. If you are using a work computer just don’t install anything and if you employer blocks sites don’t bitch about it. Also, consider installing WOT (Web of Trust) or similar browser plug-ins.

Tuesday, May 06, 2008

Work and prison

When you think about the differences between work and prison, maybe prison isn't so bad...

IN PRISON.......You spend the majority of your time in an 8x10 cell.
AT WORK........You spend most of your time in a 6x8 cubicle.

IN PRISON.......You get three meals a day.
AT WORK........You get a break for 1 meal and you have to pay for it.

IN PRISON.......You get time off for good behavior.
AT WORK........You get rewarded for good behavior with more work.

IN PRISON.......A guard locks and unlocks all the doors for you.
AT WORK........You must carry around a security card and unlock and open all the doors yourself.

IN PRISON........You can watch TV and play games.
AT WORK.........You get fired for watching TV and playing games.

IN PRISON.......You get your own toilet.
AT WORK........You have to share.

IN PRISON.......They allow your family and friends to visit.
AT WORK........You cannot even speak to your family and friends.

IN PRISON.......All expenses are paid by taxpayers with no work required.
AT WORK........You get to pay all the expenses to go to work and then they deduct taxes from your salary to pay for prisoners.

IN PRISON.......You spend most of your life looking through bars from inside wanting to get out.
AT WORK........You spend most of your time wanting to get out and go inside bars.

IN PRISON......There are wardens who are often sadistic.
AT WORK.......They are called supervisors.

IN PRISON.......You have unlimited time to read e-mail jokes.
AT WORK........You get fired if you get caught.

Sunday, March 02, 2008

Hello I'm Hillarobamy Clibama

"Hello, I'm Hillary Clinton"

"Hello, I'm Barack Obama"

Anybody else getting sick and damned tired of coming home and having to clear off at least one voice mail message every damned day? Anyone else frustrated at getting awakened during your lazy Sunday nap by the auto-dialers setup up by supporters of the Presidential hopefuls? I just did a Google search and evidently I'm not the only person sick of this crap.

Now that Texas and Ohio are suddenly important to Hillary and Obama, my home phone is getting at least one call a day. My girlfriend's dad was getting even more calls. Apparently, other places like New Hampshire have had the same problem. Most of the New Hampshire newspapers have printed letters from unhappy voters (and non-voters), many of whom simply said "I'm voting for this candidate" just to get the callers off their backs.

Guess what, dumb-asses. I can't stand any of the four remaining candidates for President. Clinton is all talk. Obama is another talker, just more aligned to future ideals that will be squashed by the remaining two branches. Huckabee is nut. McCain has some decent aspects but about as much charisma as tree bark; and "true conservatives" don't care for him anyways.

How did we end up with these four?

I'd consider libertarian again but the current crop of candidates for President and other offices makes me cringe. Again, is that the best you could find; what looks like a used car salesman, a Seinfeld extra, a crypt keeper, and a roller derby cross-dresser.

Anybody else out there just begging for consensus? Do you want to see something besides the conservative and liberal war parties fighting for this all-or-nothing cause when a democracy should build upon the commonalities between the people and place power of the government where it logically belongs? Anybody else believe that there is a place for big government, local government, and no-government?

Tuesday, February 26, 2008

A few jokes

Just a few jokes for today...

HAVE YOU FORGIVEN YOUR ENEMIES?......

Toward the end of the church service, the minister asked, "How many of you have forgiven your enemies?" About 80% held up their hands. The minister then repeated the question and all responded by raising their hands except one small, elderly lady.

"Mrs. Jones? Are you not willing to forgive your enemies?", the minister asked.

"I don't have any", she replied, smiling sweetly.

"Mrs. Jones, that is indeed unusual. How old are you?"

"Ninety-eight" she replied.

"Mrs. Jones, would you come down front and tell the congregation how a person can live for ninety-eight years and not have an enemy in the world?"

The little lady tottered down the aisle, faced the congregation, smiled sweetly and said, "I outlived the bitches."

HOW TO POOP AT WORK

We've all been there but don't like to admit it. We've all kicked back in our cubicles and suddenly felt something brewing down below. As much as we try to convince ourselves otherwise, the WORK POOP is inevitable. For those who hate pooping at work, following is the Survival Guide for taking a dump at work.

CROP DUSTING
When farting, you walk briskly around the office so the smell is not in your area and everyone else gets a whiff but doesn't know where it came from. Be careful when you do this. Do not stop until the full fart has been expelled. Walk an extra 30 feet to make sure the smell has left your pants.
FLY BY
The act of scouting out a bathroom before pooping. Walk in and check for other poopers. If there are others in the bathroom, leave and come back again. Be careful not to become a FREQUENT FLYER. People may become suspicious if they catch you constantly going into the bathroom.
ESCAPEE
A fart that slips out while taking a leak at the urinal or forcing a poop in a stall. This is usually accompanied by a sudden wave of embarrassment. If you release an escapee, do not acknowledge it. Pretend it did not happen. If you are standing next to the farter in the urinal, pretend you did not hear it. No one likes an escapee. It is uncomfortable for all involved. Making a joke or laughing makes both parties feel uneasy.
JAILBREAK
When forcing a poop, several farts slip out at a machine gun pace. This is usually a side effect of diarrhea or a hangover. If this should happen, do not panic. Remain in the stall until everyone has left the bathroom to spare everyone the awkwardness of what just occurred.
COURTESY FLUSH
The act of flushing the toilet the instant the poop hits the water. This reduces the amount of air time the poop has to stink up the bathroom. This can help you avoid being caught doing the WALK OF SHAME.
WALK OF SHAME
Walking from the stall, to the sink, to the door after you have just stunk up the bathroom. This can be a very uncomfortable moment if someone walks in and busts you. As with farts, it is best to pretend that the smell does not exist. Can be avoided with the use of the COURTESY FLUSH.
OUT OF THE CLOSET POOPER
A colleague who poops at work and is damn proud of it. You will often see an Out Of The Closet Pooper enter the bathroom with a newspaper or magazine under his or her arm. Always look around the office for the Out Of The Closet Pooper before entering the bathroom.
THE POOPING FRIENDS NETWORK (P.F.N)
A group of co-workers who band together to ensure emergency pooping goes off without incident. This group can help you to monitor the whereabouts of Out Of The Closet Poopers, and identify SAFE HAVENS.
SAFE HAVENS
A seldom used bathroom somewhere in the building where you can least expect visitors. Try floors that are predominantly of the opposite sex. This will reduce the odds of a pooper of your sex entering the bathroom.
TURD BURGLAR
Someone who does not realize that you are in the stall and tries to force the door open. This is one of the most shocking and vulnerable moments that can occur when taking a poop at work. If this occurs, remain in the stall until the Turd Burglar leaves. This way you will avoid all uncomfortable eye contact.
CAMO-COUGH
A phony cough that alerts all new entrants into the bathroom that you are in a stall. This can be used to cover-up a WATERMELON, or to alert potential Turd Burglars. Very effective when used in conjunction with an ASTAIRE.
ASTAIRE
A subtle toe-tap that is used to alert potential Turd Burglars that you are occupying a stall. This will remove all doubt that the stall is occupied. If you hear an Astaire, leave the bathroom immediately so the pooper can poop in peace.
WATERMELON
A poop that creates a loud splash when hitting the toilet water. This is also an embarrassing incident. If you feel a Watermelon coming on, create a diversion. See CAMO-COUGH.

Friday, February 22, 2008

Windows networking fun

This is a partial topic, a work in progress so to speak...

For the server: in registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser\Parameters set the string values for IsDomainMaster = TRUE and MaintainServerList = Yes

For all workstations: in registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser\Parameters set the string values for IsDomainMaster = FALSE and MaintainServerList = No

Related links:

Friday, February 15, 2008

A parable worth reading

This came to my work mail address a while back...

A Japanese company (Toyota) and an American company (General Motors) decided to have a canoe race on the Missouri River. Both teams practiced long and hard to reach their peak performance before the race.

On the big day, the Japanese won by a mile. The Americans, very discouraged and depressed, decided to investigate the reason for the crushing defeat. A management team made up of senior management was formed to investigate and recommend appropriate action.

Their conclusion was the Japanese had 8 people rowing and 1 person steering, while the American team had 8 people steering and 1 person rowing. Feeling a deeper study was in order, American management hired a consulting company and paid them a large amount of money for a second opinion.

They advised, of course, that too many people were steering the boat, while not enough people were rowing. Not sure of how to utilize that information, but wanting to prevent another loss to the Japanese, the rowing team's management structure was totally reorganized to 4 steering supervisors, 3 area steering superintendents and 1 assistant superintendent steering manager. They also implemented a new performance system that would give the 1 person rowing the boat greater incentive to work harder.? It was called the 'Rowing Team Quality First Program,' with meetings, dinners and free pens for the rower. There was discussion of getting new paddles, canoes and other equipment, extra vacation days for practices and bonuses.

The next year the Japanese won by two miles. Humiliated, the American management laid off the rower for poor performance, halted development of a new canoe, sold the paddles, and canceled all capital investments for new equipment. The money saved was distributed to the senior executives as bonuses and the next year's racing team was outsourced to India.

Thursday, February 07, 2008

ORA-22992 Oracle hell

Welcome to my little corner of hell today. A third party vendor changed their tables structures recently, adding a CLOB field to some of their tables. Like most hard working technical folk we have had to write a lot of new code to provide functionality the third party vendor does not and will not provide. So some perfectly good ANSI standard SQL suddenly puked out a "ORA-22992: cannot use LOB locators selected from remote tables" error.

I'm not using any LOB's in the queries so why in the blue heck does Oracle want to their LOB locators? I did a search and thankfully found where someone on Oracle's forums just tried to use the WHERE clause to join instead of the JOIN statement and it worked. I tried it on and sure enough, it worked. It goes something like this:

table1
crap1 VARCHAR2(10)
crap2 DATE

table2
poop1 VARCHAR2(10)
poop2 DATE
poop3 CLOB

SELECT crap2,poop2
FROM table1@remote JOIN table2@remote ON crap1 = poop1;

ERROR at line 1:
ORA-22992: cannot use LOB locators selected from remote tables

SELECT crap2,poop2
FROM table1@remote, table2@remote WHERE crap1 = poop1;

data
glorious data

There is nothing we geeks hate more than code that should work but doesn't. Especially when the people we work for are paying five, six, seven or more figures for this software. The problem was originally noticed over two and a half years ago!

M*^!@f^((#&$