0

I tried to create an Oracle PL/SQL package in Db2, but ran into errors.

   CREATE OR REPLACE PACKAGE ARITHMETIC AS
       function add (
          first number,
          second number)
       return number;
    END ARITHMETIC;


    CREATE OR REPLACE PACKAGE BODY ARITHMETIC AS
      function add(
          first number,
          second number)
       return number AS

      BEGIN
       return first + second;
      END add;
    END ARITHMETIC;

When I run the above code, it results in the following error:

Deploy [tnbdr]DB2INST1.ARITHMETIC Running DB2INST1.ARITHMETIC - Deploy for debug started. Create PL/SQL Package Specification returns SQLCODE: -104, SQLSTATE: 42601. DB2INST1.ARITHMETIC: 1: An unexpected token "PACKAGE" was found following "CREATE OR REPLACE ". Expected tokens may include:

"VIEW".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.18.60 An unexpected token "PACKAGE" was found following "CREATE OR REPLACE ". Expected tokens may include: "VIEW".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.18.60 DB2INST1.ARITHMETIC - Deploy for debug failed. DB2INST1.ARITHMETIC - Roll back completed successfully.

How can I deploy the package, why is it failing?

davejal
  • 6,009
  • 10
  • 39
  • 82
raj
  • 51
  • 2
  • 5

1 Answers1

1

Db2 supports the compilation / creation of PL/SQL packages when the database is set up for Oracle compatibility:

db2set DB2_COMPATIBILITY_VECTOR=ORA
db2stop
db2start

Bit 12 in the DB2_COMPATIBILITY_VECTOR enables PL/SQL compilation.

data_henrik
  • 16,724
  • 2
  • 28
  • 49