here you go
Code: 
http://www.swish-db.com/tutorials/view.php/tid/290
Hope it help.