A function code for generating a luiNorm within Oracle

This page is contributed by Mr. McCully Dwayne (NIH/NLM/LHC) to show a function code for generating a luiNorm within Oracle

I. Java Code: LuiNormWrapper.java


import gov.nih.nlm.nls.lvg.Api.LuiNormApi;
import java.io.*;
import java.util.*;

public class LuiNormWrapper {
public static LuiNormApi api;
public static String luinorm(String str) throws Exception {
if (api == null) {
api = new LuiNormApi("/site/package/lvg/lvg2006p/data/config/lvg.properties");
}

if (api == null) return "null";
return api.Mutate(str);
}

public static void cleanup() {
api.CleanUp();
}

public static void main (String[] s) {
try {
System.out.println(luinorm("abc"));} catch (Exception e) { e.printStackTrace(); }
}
}

II. Build & Integrate

Csh> loadjava -user user/pwd@TRUNK -verbose -force -resolve /site/package/lvg/lvg2006p/lib/lvg2006pdist.jar
Csh> /usr/bin/javac LuiNormWrapper.java
Csh> loadjava -user user/pwd@TRUNK LuiNormWrapper.class

III. Oracle Interface

SQLPLUS> CREATE OR REPLACE FUNCTION luinorm (STR IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'LuiNormWrapper.luinorm(java.lang.String) return java.lang.String';
/
SHOW ERRORS

QLPLUS> CREATE OR REPLACE PROCEDURE cleanup AS LANGUAGE JAVA NAME 'LuiNormWrapper.cleanup()';
/
SHOW ERRORS

SQL> select luinorm('left') from dual;

LUINORM('LEFT')
--------------------------------------------------------------------------------

leaf