Java SP Wrapper - 4
The wrapper sp source code:
CREATE PROCEDURE sp_demo_proc
( IN to_be_searched VARCHAR ( 1000 ),
IN search_for VARCHAR ( 1000 ),
OUT last_index INTEGER )
BEGIN
DECLARE demo_proc_arg DemoProcArg;
SET demo_proc_arg = NEW DemoProcArg();
MESSAGE 'sp: to_be_searched = ', to_be_searched;
MESSAGE 'sp: search_for = ', search_for;
CALL DemoProc >> javaProc
( to_be_searched, search_for, demo_proc_arg );
SET last_index = demo_proc_arg >> returnArg;
MESSAGE 'sp: last_index = ', last_index;
END
Notes:
The sp_demo_proc stored procedure declares a local variable of type DemoProcArg, then uses the "NEW <constructor call>" syntax to create (instantiate) an actual object of that type and assign it to the variable. The "CALL DemoProc >> javaProc" statement calls the static method inside the DemoProc class without having to instantiate an object of type DemoProc. This call passes the demo_prog_arg object variable, and after the call the field returnArg is available to display.