I an trying to create new stored procedures.
Below is the code segment for sp.
CREATE PROCEDURE abs_eq (arg1 INTEGER, arg2 INTEGER)
RETURNS BOOLEAN
WITH (NOT VARIANT)
DEFINE ret BOOLEAN;
IF (arg1 < 0 THEN)
LET arg1 = -arg1;
END IF
IF(arg1 = arg2) THEN
LET ret = "t";
ELSE
LET ret = "f";
END IF;
RETURN ret;
END PROCEDURE;
EXECUTE PROCEDURE abs_eq (3, 5);
However, I don’t know where to put this code segment and how to compile at remote database.
I will call this functions in java like this:
public void callfunction() throws SQLException {
CallableStatement proc = null;
proc = conn.prepareCall("{ call abs_eq(?,?) }");
proc.setInt(1, 3);
proc.setInt(2, 5);
boolean result = proc.execute();
System.out.println(result);
}
I need a clear explanation that describes what I need to do step by step
You can “put” it on database using any tool that can run sql statements. This can be done by ISA (Informix Server Administrator), or SQL Editors working with ODBC or JDBC drivers. Of course you can use JDBC to this task:
I use it with Informix JDBC driver and Jython (so, no semicolons at line ends).
You have some errors in procededure. It should be function, and if I understand its name it should compare two ints using their absolute values. I would write it that way:
I would also add some tests, there is Jython code with test routine and tests: