Oninit® SQLMorph — Informix Java UDR
Informix's other in-engine procedural runtime: J/Foundation Java UDRs. SQLMorph emits one <name>.java per procedure plus a CREATE FUNCTION install SQL script that wires the Java method up under the same name as the source SPL. All emitted classes pack into one sqlmorph.jar; the install SQL references it through the sqlj.install_jar-registered identifier sqlmorph_jar.
What gets emitted
| File | Contents |
|---|---|
| <name>.java | Java source: package com.oninit.sqlmorph;, import java.sql.*;, one public class with one public static method matching the procedure name. SPL types mapped to Java primitives or java.sql.* types. |
| <name>_install.sql | DROP FUNCTION IF EXISTS then CREATE FUNCTION … EXTERNAL NAME 'sqlmorph_jar:com.oninit.sqlmorph.<name>.<name>(args)return' LANGUAGE JAVA NOT VARIANT WITH (class = "jvp");. |
| Makefile | One canonical generic Makefile at /sqlmorph/makefile.html — make jar compiles every *.java into sqlmorph.jar, make IFXDB=mydb java-install registers the JAR plus every procedure. |
| REPORT.md | Only emitted when constructs were flagged. Each entry carries file:line, the construct, and a one-line note explaining what to review. |
Type mapping
| SPL type | Java type |
|---|---|
| SMALLINT | short |
| INT / INTEGER / SERIAL | int |
| INT8 / BIGINT / SERIAL8 / BIGSERIAL | long |
| FLOAT / DOUBLE PRECISION | double |
| SMALLFLOAT / REAL | float |
| DECIMAL / NUMERIC / MONEY | java.math.BigDecimal |
| CHAR / VARCHAR / LVARCHAR / NCHAR / NVARCHAR | String |
| DATE | java.sql.Date |
| DATETIME | java.sql.Timestamp |
| INTERVAL | String (parse with com.informix.lang.IfxInterval) |
| BOOLEAN | boolean |
| TEXT / CLOB | java.sql.Clob |
| BYTE / BLOB | java.sql.Blob |
In-engine SQL
SPL procedures that run in-engine SQL (FOREACH cursors, dynamic PREPARE/EXECUTE, raw SELECT/INSERT/ UPDATE/DELETE) acquire the implicit server connection through Informix J/Foundation's standard idiom:
Connection conn = DriverManager.getConnection("jdbc:default:connection");
FOREACH cursors translate to PreparedStatement + ResultSet loops. INTO targets dispatch to the typed ResultSet getter per the SPL local's type (getInt, getFloat, getString, …). ON EXCEPTION wraps the body in try { … } catch (SQLException _e) with a per-handler dispatch on _e.getErrorCode().
Multi-column RETURNING
SPL functions that return more than one column use Informix's multi-return Java UDR convention: slot 0 via the Java method's normal return value, slots 1..N-1 via trailing 1-element-array OUT parameters. A RETURNING SMALLFLOAT, SMALLFLOAT, SMALLFLOAT SPL function emits as public static float <name>(float[] _ret1, float[] _ret2); the RETURN a, b, c statement assigns _ret1[0] = b; _ret2[0] = c; return a;. The install SQL's EXTERNAL NAME type-signature reflects the array params: (float[],float[])float.
Known gap: multi-column iterator returns (RETURN a, b WITH RESUME) require a Java row buffer pattern documented in the IBM Informix J/Foundation Developer's Guide. Currently flagged in REPORT.md for customer-side conversion until that work lands.
JAR registration
The JAR identifier sqlmorph_jar is registered once per database via:
EXECUTE FUNCTION sqlj.install_jar('file:///opt/informix/extend/sqlmorph/sqlmorph.jar', 'sqlmorph_jar');
make IFXDB=mydb java-install does this for you and then registers every procedure's _install.sql. To remove or replace the JAR: EXECUTE FUNCTION sqlj.remove_jar('sqlmorph_jar'); or EXECUTE FUNCTION sqlj.replace_jar(…) — standard J/Foundation admin functions.