Too be honest you won't really be able to do this. Very few handsets have the capability (mainly Samsungs) and o2 can't do it from their end.
What o2 can do for you is change your number, just call them on 202 and say you're getting nuisance calls, it's free on the first occasion.
I'm assuming that it's individuals that you want to block as opposed to companies trying to sell you something? If it is the latter though then registering your number with the telephone preference service at
www.tpsonline.org.uk can help prevent this.