« February 2010 | Main | May 2010 »
March 24, 2010
It IS Spring Break After All...
...so I better update you on my electric bicycles! Well, David from electric bikes NW in Seattle came through for me one more time and found probably the last front chain cog in existence for my aging LaFree Sport. SO, it's back on the road now with a new front cog, new rear cassette, new chain, and a new rim (old one wore right through the side!). I am no expert at setting the derailer so it needs a bit more work but at least it is working again. I can't believe how much easier it is to make short commutes on the ebike rather than using my pickup.
My first ebike build is about to get underway. I'm waiting on a rear cassette that will fit the rear hub motor (I already have two rear cassettes, but of course they don't fit). It's on the way, so should be here by the weekend. That will allow me to get the rear wheel setup with a hub motor and 7 speed cassette. Then it's a trip to the bike shop for tires, front fork, handlebars, and who knows what all else. I'll keep you posted as it moves forward.
Posted by rossm at 3:44 PM | Comments (0)
A Little Bit of SWAMP Coding
I was asked to prepare a new form/report for SWAMP that allows a user to query labor data in a number of different ways. This was a good opportunity to look through some existing code for some clever ideas. One of the queries looks like this:
SELECT USER, wo_number, (name||', '||first_name), description,
work_date, hours,
hours * A.rate,b.employee
FROM table A, table B
WHERE A.employee = B.employee
AND work_date >= decode(beg_date,'',work_date,beg_date)
AND work_date <= decode(end_date,'',work_date,end_date)
AND wo_number = decode(wo1,'',wo_number,wo1)
and b.employee = decode(empno,'',b.employee,empno)
and b.name = decode(lname,'',b.name,lname)
and a.description like '%' || pdesc || '%';
Two clever things (wish I had thought of these, but they were stolen from Bryan Hockett) -first, on the last line notice how the all encompassing search through descriptions was done. pdesc is the value the user typed into the form. Second clever thing - "decodes" that handle the case if a value is null (i.e. user did not use that particular item). The way you read the decodes is like this (for example: decode(end_date,'',work_date,end_date)) if end_date is null then insert work_date, else insert end_date. So you either wind up with:
and work_date <= work_date (no harm done) OR
work_date <= end_date (if end_date has a value).
End result: You don't need to know whether end_date is null or not! The decode takes care of it for you. Veeerrrrry interrresting....
Posted by rossm at 3:29 PM | Comments (0)