Take the 2-minute tour ×
sqlStmt = new StringBuffer("  ALTER SEQUENCE "  );  
                    sqlStmt.append( ServerContext.getSchemaName() );
                    sqlStmt.append( " INCREMENT BY " );
                    sqlStmt.append( " ? " );
pstmt.setLong(1, incval);
share|improve this question
what is the type of incval ? –  Jigar Joshi Apr 30 '11 at 10:31
I hope you understand what this SQL command will do, namely change the increment size of the sequence for each future call to NEXT_VAL (and not increase the current value once). I've seen several times that people have incorrectly used this statement and then run out of numbers within hours. Not only did this bring the application to a halt. There was no big enough number range left either (without a number already in use). –  Codo Apr 30 '11 at 12:26
add comment

1 Answer

up vote 4 down vote accepted

You can't use bind variables with DDL, such as ALTER SEQUENCE. You'll have to concatenate incval onto the string.

There shouldn't be any risk of SQL injection if incval is an int or a long.

share|improve this answer
thnx a ton Luke.. it worked by concatenateing incval onto the string. –  smriti May 2 '11 at 4:13
add comment

Your Answer


