psql syntax error at or near "+"

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

Answers


You can use function setval() with an expression:

\set startSmallOffset 1000000
\set traineeNext :startSmallOffset+2000

select setval('record_trainee_id_seq', :traineeNext);

Need Your Help

How to call partial view through ajax in mvc3

ajax asp.net-mvc-3 asp.net-mvc-ajax

I need to call a partial view through ajax. I have tried the following, but I am not sure how to complete it.