簡體   English   中英

SimpleJdbcCall:如何將包含另一個SQL類型的數組的SQL類型的Oracle數組映射/發送到Oracle存儲過程?

[英]SimpleJdbcCall : How to Map/Send an Oracle Array of SQL Type which contains an array of another SQL Type to an Oracle Stored Procedure?

這是我要發送到oracle過程的Bean結構嗎?

public class DMSApplicantIdScanningData {
    private String refId;
    private String applicantType;
    private String applicantName;
    private List<DMSDocument> dmsDocuments;
    //getter and setter methods
}

public class DMSDocument {
    private String documentName;
    private String category;
    private Date scannedDate;
    //Getter and Setter Methods
}

我想將DMSApplicantIdScanningData列表作為輸入參數發送到oracle過程嗎?

到目前為止,我已經嘗試過了

this.saveScannedDataJdbcCall = new SimpleJdbcCall(dataSource).withCatalogName("PKG_DMS_RCU").
withProcedureName("PRC_SAVE_DMS_SCANNING_DATA").declareParameters(
    new SqlParameter("P_FAN_NO",Types.VARCHAR) ,
    new SqlParameter("P_DSA_NAME",Types.VARCHAR) ,
    new SqlParameter("P_BDM_NAME",Types.VARCHAR) ,
    new SqlParameter("P_FAN_NO",Types.VARCHAR) ,
    new SqlParameter("P_DMS_APPLICANT_SCANNING_ARRAY",OracleTypes.ARRAY,"T_DMS_APPLICANT_SCANNING_ARRAY"),
    new SqlOutParameter("P_MSG", Types.VARCHAR)
); 

但是,這不起作用。

如果需要更多有關問題的信息,請在下面評論

我認為您需要遵循這個項目: http : //docs.spring.io/spring-data/jdbc/docs/current/reference/html/orcl.datatypes.html

您的代碼應如下所示:

ARRAY create(List<Map> data, String tableName, String recordName) {
        def recordKeys = internalProperties.getProperty(recordName.replaceFirst(/.*\./, '')).split(',')
        def connection = nativeConnection
        def structDescriptor = StructDescriptor.createDescriptor(recordName, connection)

        def dataArray = []

        data.each { recordMap ->
            def record = []
            if (recordMap) {
                recordKeys.each {
                    record << recordMap[it]
                }
                dataArray << new STRUCT(structDescriptor, connection, record.toArray())
            }
        }

        new ARRAY(ArrayDescriptor.createDescriptor(tableName, connection), connection, dataArray.toArray())
    }

(對不起,Groovy代碼:-))

這個想法是:為每個列表項創建STRUCT並為適當的過程參數構建ARRAY

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM