SQL definitions for a variable-length UDT example
The SQL definitions for this example are:
-- VarLen UDT and support functions ----------------------------
create opaque type Record3 (internallength = variable,
alignment = 8, maxlen = 2048, cannothash );
grant usage on type Record3 to public;
-- register JUDT implementation....
-- note package name needs to match class file package
execute procedure setUDTExtName("Record3",
"informix.testclasses.jlm.udt.Record3");
-- Definitions for NON_DEFAULT Input/Output functions.
-- this overrides the defaults setup above
-- LVARCHAR INPUT
drop cast (Record3 as lvarchar);
create implicit cast (Record3 as lvarchar with record3_output);
create function record3_input (l lvarchar) returns Record3
external name
‘informix.testclasses.jlm.udt.Record3.fromString(java.lang.String)’
language java not varient;
grant execute on function record3_input to public;
-- CHAR INPUT
drop cast (Record3 as char(100));
create implicit cast (Record3 as char(100) with record3_rout);
create function record3_rin (c char(100)) returns Record3
external name
‘informix.testclasses.jlm.udt.Record3.fromString(java.lang.String)’
language java not varient;
grant execute on function record3_rin to public;
-- LVARCHAR OUTPUT
drop cast (lvarchar as Record3);
create explicit cast (lvarchar as Record3 with record3_input);
create function record3_output (c Record3) returns lvarchar
external name
‘informix.testclasses.jlm.udt.Record3.makeString(informix.testclasses.jlm.udt.Record3)’
language java not varient;
grant execute on function record3_output to public;
-- CHAR OUTPUT
drop cast (char(100) as Record3);
create explicit cast (char(100) as Record3 with record3_rin);
create function record3_rout (c Record3) returns varchar(100) external name
‘informix.testclasses.jlm.udt.Record3.makeString(informix.testclasses.jlm.udt.Record3)’
language java not varient;
grant execute on function record3_rout to public;
-- END definitions for NON_DEFAULT Input/Output functions.
-- end VarLen UDT and support functions --------------------------
-- Example Usage ---
create table rec3tab (record_col Record3);
insert into rec3tab values (‘665.999 JAVA 398 197.236 1952-04-10 47 f t t’);
insert into rec3tab values (‘667.000 Jive 983 791.632 2002-04-11 42 f f f f f’);
select * from rec3tab;