1

I'm trying to use arithmetic calculation:

\set startSmallOffset 1000000
\set traineeNext :startSmallOffset+2000

ALTER SEQUENCE record_trainee_id_seq RESTART WITH :traineeNext

The error:

ERROR: syntax error at or near "+" LINE 1: ALTER SEQUENCE record_trainee_id_seq RESTART WITH 1000000+2000...

It works if I remove '+2000'

Appreciate any advice

Roy Shmuli
  • 4,979
  • 1
  • 24
  • 38
  • 1
    The value for the `restart with` can't be an expression - it must be a constant value. –  Jul 09 '15 at 11:02

1 Answers1

1

You can use function setval() with an expression:

\set startSmallOffset 1000000
\set traineeNext :startSmallOffset+2000

select setval('record_trainee_id_seq', :traineeNext);
klin
  • 112,967
  • 15
  • 204
  • 232