If you are focussed on writing prcedures in SQL, you may have a look at the docs, e.g. this introduction. They contain several examples.
And besides: If you have a programming task and don't know how to express this as a procedure/function - just ask on this site:)
answered 11 Dec '10, 13:51