create or replace and compile java source named test_anytype_pack as
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.*;
public class test_anytype
{
public static TypeDescriptor get_anytype ()
throws Exception
{
TypeDescriptor v_anytype = null ;
Connection conn = null;
OracleDriver ora = new OracleDriver();
conn = ora.defaultConnection();
OracleCallableStatement cstmt = null ;
try
{
cstmt = (OracleCallableStatement)conn.prepareCall
( " declare\n" +
" atyp anytype;\n" +
" begin\n" +
" anytype.begincreate( dbms_types.typecode_object, atyp );\n" +
" atyp.addattr\n" +
" ( 'f1'\n" +
" , dbms_types.typecode_number\n" +
" , null\n" +
" , null\n" +
" , null\n" +
" , null\n" +
" , null\n" +
" ) ;\n" +
" atyp.addattr\n" +
" ( 'f2'\n" +
" , dbms_types.typecode_varchar2\n" +
" , NULL\n" +
" , NULL\n" +
" , 100\n" +
" , null\n" +
" , null\n" +
" ) ;\n" +
" atyp.endcreate;\n" +
" ? := atyp ;\n" +
" end ;"
) ;
cstmt.registerOutParameter ( 1 , OracleTypes.OPAQUE , "SYS.ANYTYPE" ) ;
cstmt.execute() ;
v_anytype = (TypeDescriptor)cstmt.getObject(1);
cstmt.close();
}
finally
{
if ( cstmt != null ) cstmt.close() ;
}
return v_anytype ;
}
}
ORA-04088: error during execution of trigger 'SYS.DBCLOUD_BEFORE_DDL_DB_TRG' ORA-06512: at "SYS.DBCLOUD_SYS_SEC", line 1838 ORA-06512: at "SYS.DBCLOUD_SYS_SEC", line 2047 ORA-06512: at line 2More Details: https://docs.oracle.com/error-help/db/ora-04088
CREATE OR REPLACE FUNCTION get_anytype_j2
return anytype
as language java name 'test_anytype.get_anytype () return oracle.sql.TypeDescriptor' ;
Function created.
DECLARE
atyp anytype;
outset anydataset ;
BEGIN
atyp := get_anytype_j2 ;
anydataset.begincreate( dbms_types.typecode_object, atyp, outset );
for i in 1 .. 5
loop
outset.addinstance;
outset.piecewise();
outset.setnumber( i );
outset.setvarchar2( 'row: ' || to_char( i ) );
end loop;
outset.endcreate;
END ;
ORA-29540: class test_anytype does not exist ORA-06512: at "SQL_NSNNLXPEIJOPCTCFBEMAWVPFH.GET_ANYTYPE_J2", line 1 ORA-06512: at line 6 ORA-06512: at "SYS.DBMS_SQL", line 1721More Details: https://docs.oracle.com/error-help/db/ora-29540