Monday, March 27, 2006

Go pedal power

We now have a company bike! Its not a bad bike either. I have decided to start using it for getting around town and its so cool. Why did I not do this years ago? Its good for fitness and its quick and easy, no parking worries etc. There is something about riding a bike to a client in the city which just makes me feel so cultured! Of course, this is a delusion.

Wednesday, March 15, 2006

Mmmmm.....email

Can't say too much now but there is a new kid on the block. An email plugin for NetFox which talks directly to Exchange. Real time mailstats for the Fox! Think I'll call it MailWorks :) Hopefully we will start beta testing in the next few weeks so stay tuned!

Saturday, March 11, 2006

Serial types in postgresql views using INSERT INSTEAD rules

Discovered a little trick last week in postgres. When you want to write to a table via its view instead of directly by using a rule it can be tricky to get the serial primary key values to set properly. What you want is for the view to behave in just the same way as a normal table. So when you provide a value for the serial it uses that, otherwise it just autoincrements.


First set up a backend table:

CREATE TABLE my_data (
id serial primary key,
somevalue text,
--more data
);

Using a serial value will create the sequence my_data_id_seq which we can use later.
Next create the view:

CREATE VIEW my_view AS SELECT id,somevalue... FROM my_data;

Now here is the trick. I want to insert data into my_view instead of my_data directly but the data needs to actually be stored in my_data. We do this:

CREATE RULE my_view_insert AS ON INSERT TO my_view DO INSTEAD
INSERT INTO my_data (id,somevalue) VALUES (COALSECE(NEW.id, nextval('my_data_id_seq'::text)),NEW.somevalue);

The real kicker is the COALSECE(NEW.id, nextval('my_data_id_seq'::text)) bit. It says that if an id is explicitly set then use that otherwise use the next value in the sequence. Neat, huh?

Friday, March 03, 2006

The week of the 100's


Yesterday I committed revision 100 of the NetFox Scope interface into svn. Although there is nothing special about this revision it marks a milestone of a lot of hard work for Tim and I. Thats 100 revisions of 3.8 already and we haven't even officially released yet! The other 100 we hit this week was 100 empty bottles of nudies and emma and toms health juices. Unlike the stereotypical software developers with their coke, pizza and potato chips, we have adpoted the staples of fruit juices, green tea and protein shakes. Just another thing that makes Boxen Systems different.