views:

28

answers:

1

I have two variables

MAX_TABLE_ID INTEGER;
NEXT_TABLE_ID INTEGER;

I'm reading values into these and then trying to alter a sequence based on them

EXECUTE IMMEDIATE 'ALTER SEQUENCE NEXT_VALIDATED_TABLE_ID INCREMENT BY [MAX_TABLE_ID-NEXT_TABLE_ID]';

Bit I'm getting an "invalid number" error or a SQL command not ended error.

This even happens if I try hardcoded numbers

ALTER SEQUENCE NEXT_VALIDATED_TABLE_ID INCREMENT BY 100-1; or

ALTER SEQUENCE NEXT_VALIDATED_TABLE_ID INCREMENT BY [100-1];

Am i missing something obvious here

+1  A: 

I'd try doing the calculation outside the literal, eg

EXECUTE IMMEDIATE 'ALTER SEQUENCE NEXT_VALIDATED_TABLE_ID INCREMENT BY ' || MAX_TABLE_ID-NEXT_TABLE_ID;
Hobo
Good thinking, that worked.
AJM