"McLaughlin, Michael" <McLaughlinM(at)byui(dot)edu> writes:
> Code including test:
> err_num INTEGER;
> err_num := SQLSTATE;
I see no bug here. SQLSTATE's value is not necessarily an integer [1],
so you shouldn't be trying to store it in one.
regards, tom lane
[1] https://www.postgresql.org/docs/current/errcodes-appendix.html