Josh and anyone interested, I've slightly changed the function. C source of a standalone program is available from http://www.primechoice.com/hum/uspn.c Comments welcome. Thx Ed PS Lemme know if you need a function, callable from PGSQL -- Well I tried to be meek And I have tried to be mild But I spat like a woman And I sulked like a child I have lived behind the walls That have made me alone Striven for peace Which I never have known Dire Straits, Brothers In Arms, The Man's Too Strong (Knopfler)