mixm
mixm

Reputation: 531

db2 programming

I'm currently porting a MySql database to DB2. So far, I've been able to migrate the tables, but unfortunately the functions and the triggers need to be manually migrated. I've read about pl/sql for DB2, but it isn't supported in the express-c version of DB2. Are there any alternatives on how i can convert mysql functions and triggers to DB2?

Upvotes: 1

Views: 567

Answers (2)

Shelton Reese
Shelton Reese

Reputation: 1

As long as you stay inside of the SQL-92 standard you will have no problems - otherwise - you will have to create a few procedures to enhance compatibility I did one for BIT_XOR:

CREATE FUNCTION BITAND (N1 Integer, N2 Integer)
RETURNS Integer
SPECIFIC BITANDMySQL
LANGUAGE SQL
CONTAINS SQL
NO EXTERNAL ACTION
DETERMINISTIC
RETURN
WITH
Repeat (S, M1, M2, Ans) AS
(Values (0, N1, N2, 0)
Union All
Select S+1, M1/2, M2/2, Ans+MOD(M1,2)*MOD(M2,2)*power(2,S)
From Repeat
Where M1 > 0
AND M2 > 0
AND S < 32
)
SELECT ANS
FROM Repeat
WHERE S = (SELECT MAX(S)
FROM Repeat)
;

Upvotes: 0

Leo
Leo

Reputation: 1514

I think you are confusing PL/SQL (an Oracle compatibility layer) with SQL PL, a procedural language built into all editions of DB2, including DB2 Express-C.

You can, in fact, define stored procedures, functions, and triggers in DB2 Express-C. There should be some info about it in the Getting Started e-book.

Upvotes: 5

Related Questions