关于如何从JDBC检索/编写Oracle表类型的之后,是否可以直接检索类型元数据,或者只检索类型的名称(然后可以与Oracle结合使用)司机this question获取所需数据?)
具体来说,考虑到这个程序:
CREATE OR REPLACE PROCEDURE andrew_test (
p_in_num_param IN NUMBER
, p_in_char_param IN VARCHAR2
, p_in_date_param IN DATE
, p_in_adt_param IN sw_ty_number_array
, p_out_num_param OUT NUMBER
, p_out_char_param OUT VARCHAR2
, p_out_date_param OUT DATE
, p_out_adt_param OUT sw_ty_number_array
, p_inout_num_param IN OUT NUMBER
, p_inout_char_param IN OUT VARCHAR2
, p_inout_date_param IN OUT DATE
, p_inout_adt_param IN OUT sw_ty_number_array
) AS
BEGIN
NULL;
END;
/
这个Java代码(假设ParameterMetadata只是一个POJO):
Connection conn = dataSource.getConnection();
DatabaseMetaData metadata = conn.getMetaData();
rs = metadata.getProcedureColumns(packageName, this.schemaName, procedureName, null);
while(rs.next()) {
ProcedureParameter param = new ProcedureParameter(rs.getString("COLUMN_NAME"), rs.getInt("DATA_TYPE"), rs.getInt("COLUMN_TYPE"), rs.getString("TYPE_NAME"));
System.out.println(param);
}
检索比SQL Type ID 1111(“Other”)和类型名称“TABLE”更有意义的内容(最好是sw_ty_number_array)。
ProcedureParameter [parameterName=P_IN_NUM_PARAM, sqlType=3, parameterType=1, parameterTypeName=NUMBER]
ProcedureParameter [parameterName=P_IN_CHAR_PARAM, sqlType=12, parameterType=1, parameterTypeName=VARCHAR2]
ProcedureParameter [parameterName=P_IN_DATE_PARAM, sqlType=93, parameterType=1, parameterTypeName=DATE]
ProcedureParameter [parameterName=P_IN_ADT_PARAM, sqlType=1111, parameterType=1, parameterTypeName=TABLE]
ProcedureParameter [parameterName=P_OUT_NUM_PARAM, sqlType=3, parameterType=4, parameterTypeName=NUMBER]
ProcedureParameter [parameterName=P_OUT_CHAR_PARAM, sqlType=12, parameterType=4, parameterTypeName=VARCHAR2]
ProcedureParameter [parameterName=P_OUT_DATE_PARAM, sqlType=93, parameterType=4, parameterTypeName=DATE]
ProcedureParameter [parameterName=P_OUT_ADT_PARAM, sqlType=1111, parameterType=4, parameterTypeName=TABLE]
ProcedureParameter [parameterName=P_INOUT_NUM_PARAM, sqlType=3, parameterType=2, parameterTypeName=NUMBER]
ProcedureParameter [parameterName=P_INOUT_CHAR_PARAM, sqlType=12, parameterType=2, parameterTypeName=VARCHAR2]
ProcedureParameter [parameterName=P_INOUT_DATE_PARAM, sqlType=93, parameterType=2, parameterTypeName=DATE]
ProcedureParameter [parameterName=P_INOUT_ADT_PARAM, sqlType=1111, parameterType=2, parameterTypeName=TABLE]
答案 0 :(得分:0)
目前,我们无法找到可行的解决方案。
目前的替代方法是查询视图user_arguments
并手动检索数据。