Hello,
Have you tried to create a user defined function for replace? You can do
that using the CREATE FUNCTION statement
(http://db.apache.org/derby/docs/10.1/ref/rrefcreatefunctionstatement.html).
I have tried creating a very simple java method that does the replace
and it seems to work fine.
Here is what I tried:
1. Java method
public static String replace (String orgStr, String oldStr, String
newStr) {
return orgStr.replace(oldStr, newStr);
}
2. User defined function
CREATE FUNCTION REPLACE(orgStr VARCHAR(50), oldStr VARCHAR(50),
newStr VARCHAR(50)) RETURNS VARCHAR(50)
PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA
EXTERNAL NAME 'StringReplaceTest.replace';
3. Test
ij> values replace('fernanda', 'a', 'e');
1
--------------------------------------------------------------------------------------------------------------------------------
fernende
1 row selected
Best regards,
Fernanda
[EMAIL PROTECTED] wrote:
Hello,
First I apologize for my poor english...
I'm looking for a simple way to implement a character replacement function.
I'm trying to do an application migration from WSAD/DB2 to Tomcat/Derby but
there are a lot of SQL queries which use the REPLACE(SOURCE STRING, OLD
CHARACTER, NEW CHARACTER) function. It seems that this function is not
built into Derby.
Do you have an idea?
Best regards
Cédric