"Graham Vickrage" <graham@digitalplanit.com> writes:
> I essentially need the last four digits of the number (securing
> credit card numbers is the idea), which I can only do by manipulating text
> and casting it back.
What's wrong with a modulo operation?
regression=# select '123456789'::int8 % 10000::int8;?column?
---------- 6789
(1 row)
regards, tom lane