Hi All,
I wan to update the identity column of a table using dynamic SQL in a Stored procedure.
below is the Proc, table TBLM has A_ID column as identity.
CREATE PROCEDURE DYNSQLSAMPLE()
LANGUAGE SQL
BEGIN
DECLARE stmt VARCHAR(256);
DECLARE mgrno INT;
SET mgrno = 8888;
SET STMT1 = 'ALTER TABLE TBLM ALTER COLUMN A_ID RESTART WITH ? ';
PREPARE s1 FROM stmt;
EXECUTE s1 USING mgrno;
END
This proc is building properly but when I am running it in debug mode it if failing with the below error message
DB2USR1.DYNSQLSAMPLE - Debug started.
DYNSQLSAMPLE - Exception occurred while debugging:
A database manager error occurred.[IBM][CLI Driver][DB2/LINUX] SQL0104N An unexpected token "?" was found following "MN A_ID RESTART WITH". Expected tokens may include: "<signed_numeric_literal>". SQLSTATE=42601
DYNSQLSAMPLE - Roll back completed successfully.
DB2USR1.DYNSQLSAMPLE - Debug failed.
Could any one please let me know what I am doing wrong here..?
Thanks