Thanks Geraint.
I did roughly the same thing so currval wasn't needed at all. But your
way confirms currval is not the source of the problem.
Incidentally I had previously tried using a view, on the basis that
any query can be a view. It turns out querying a sequence in a view is
explicitly disallowed.
I cannot think what the justification would be. It's an annoying
exceptional case. But hey-ho; it's SQL. :-P
Roy