Sybase stored procedures migrated to DB2 error collection-constantly updating __ storage

Source: Internet
Author: User
Tags db2 db2 error db2 sql error sql error sybase sybase database

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.