Because of the work need to migrate the Sybase database stored procedures to the DB2 database, because I have not contacted Sybase and DB2 so this learning process is relatively tortuous, I will be the migration process encountered in the various problems summarized together, easy to read later, The collection will continue to add content as the learning progresses ...
Collection format:
Error Tip: ...
Workaround: ...
1. Error tip: DB2 SQL error:sqlcode=-104,sqlstate=42601, Sqlerrmc=<cursor declaration>;; <sql statement>,driver=3.50.152
Message: anunexpected token "<cursor declaration>" was found following "<cursor declaration>".
Expected tokens may include: "<sql statement>". sqlcode=-104, sqlstate=42601,driver=3.50.152
WORKAROUND: DB2 Declare variables to be ordered: first declare: ordinary variable; second declaration: cursor; Final statement: Condition handler. After placing the declaration position of a cursor after a normal variable
2. Error tip: DB2 SQL error:sqlcode=-104,sqlstate=42601, sqlerrmc=<variabledeclaration>;; <sql statement>,driver=3.50.152
Message: A unexpected token "<variable declaration>" was found following "<variabledeclaration>".
Expected tokensmay include: "<sql statement>". sqlcode=-104, sqlstate=42601, driver=3.50.152
WORKAROUND: DB2 Declare variables to be ordered: first declare: ordinary variable; second declaration: cursor; Final statement: Condition handler. Place the declaration position of the generic variable to the front.
3. Error tip: DB2 SQL error:sqlcode=-440,sqlstate=42884, Sqlerrmc=patindex; FUNCTION, driver=3.50.152
Message: noauthorized routine named "PATINDEX" of type "FUNCTION" has compatible arguments was found ... sqlcode=-440, sqlstate=42884,driver=3.50.152
Workaround: Replace the PATINDEX function with the locate function.
4. The global variable in Sybase @ @rowcount How to use it in DB2. Online solutions are as follows:
A: DB2 also has this global variable, the specific use of the following:
By declaring the variable tempcount, use the statement
DECLARE tempcount BIGINT DEFAULT = 0;
Get diagnostics Tempcount = Row_count;
Question: I will report the error when I follow the above solution Sqlcode =-401 error
WORKAROUND: Change the definition type BIGINT to INT