DB2 does not specify schema call stored procedure failed sqlcode=-440, sqlstate=42884

Source: Internet
Author: User
Tags db2

Phenomenon
The user name for Db2,schema and access db is inconsistent.
The schema must be specified when the stored procedure is called, otherwise error.

Error code
Stored Procedures

        SET SCHEMA = "QUOTATION";        SET CURRENT PATH = "SYSIBM","SYSFUN","SYSPROC","SYSIBMADM","DB2INST1";        CREATE PROCEDURE COPY_QUOTATION_TABLES (。。。。。。)        BEGIN                。。。。。。        END;        GRANT EXECUTE ON PROCEDURE "QUOTATION"."COPY_QUOTATION_TABLES"( VARCHAR(36), VARCHAR(36), INTEGER, TIMESTAMP, INTEGER, INTEGER ) TO USER "DB2INST1" WITH GRANT OPTION;

Mapper.xml

        <update id="copyQuotationTables" statementType="CALLABLE" parameterType="map">                CALL COPY_QUOTATION_TABLES (                    #{quotationId, jdbcType=VARCHAR, mode=IN}                    , #{newQuotationId, jdbcType=VARCHAR, mode=IN}                    , #{userId, jdbcType=INTEGER, mode=IN}                    , #{currentTime, jdbcType=TIMESTAMP, mode=IN}                    , #{reasonTypeFlag, jdbcType=INTEGER, mode=IN}                    , #{copyReason, jdbcType=INTEGER, mode=IN} )        </update>

Mapper.java

        /**         * Copy Quotation Tables          *         * @param param the parameter         */        void copyQuotationTables(Map<String, Object> param);

Service.java

        Map<String, Object> paramMap = new HashMap<String, Object>();        paramMap.put("quotationId", quotationId);        paramMap.put("newQuotationId", newQuotationId);        paramMap.put("userId", userId);        paramMap.put("currentTime", currentTime);        paramMap.put("reasonTypeFlag", 1);        paramMap.put("copyReason", 1);        Mapper.copyQuotationTables(paramMap);

Tomcat Context.xml

    <Resource name="jdbc/testDS" auth="Container" type="javax.sql.DataSource"              driverClassName="com.ibm.db2.jcc.DB2Driver"              url="jdbc:db2://127.0.0.1:50000/test:currentSchema=QUOTATION;"              username="db2inst1" password="db2inst1" maxActive="100"  maxIdle="30"/>

Correct code
The Tomcat context.xml is appended with Currentfunctionpath.

    <Resource name="jdbc/testDS" auth="Container" type="javax.sql.DataSource"              driverClassName="com.ibm.db2.jcc.DB2Driver"              url="jdbc:db2://127.0.0.1:50000/test:currentSchema=QUOTATION;currentFunctionPath=QUOTATION;"              username="db2inst1" password="db2inst1" maxActive="100"  maxIdle="30"/>

If you want to invoke a stored procedure in a DB tool (such as: Toda), but do not specify a schema,
such as: Call Copy_quotation_tables (...) )
You need to specify the current Path when you create a stored procedure

SET CURRENT PATH = "SYSIBM","SYSFUN","SYSPROC","SYSIBMADM","DB2INST1","QUOTATION";

Reason
DB2 stored Procedures (and functions) are not controlled by the current schema, but are controlled by current path.

DB2 does not specify schema call stored procedure failed sqlcode=-440, sqlstate=42884

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.