How to passing list data variable to store procedure and execute the store procedure?

偶尔善良 提交于 2021-01-29 14:31:58

问题


I have 8 variable list and collect them to variable ls in this below code :

Workbook workbook = new Workbook("D:/excel file/Mapping Prod Matriks _Group Sales Commercial.xlsx");
    com.aspose.cells.Worksheet worksheet = workbook.getWorksheets().get(0);
    com.aspose.cells.Cells cells = worksheet.getCells();
    Range displayRange = cells.getMaxDisplayRange();
    List<String> ParaObjGroup = new ArrayList<String>();
    List<String> ParaObjCode = new ArrayList<String>();
    List<String> ParaProdMatrixId = new ArrayList<String>();
    List<String> ParaProdChannelId = new ArrayList<String>();
    List<String> ParaProdSalesGroupId = new ArrayList<String>();
    List<String> ParaCustGroup = new ArrayList<String>();
    List<String> ParaSlsThroughId = new ArrayList<String>();
    List<Integer> Active = new ArrayList<Integer>();

    for(int row= displayRange.getFirstRow()+1;row<displayRange.getRowCount();row++){
        ParaObjGroup.add(displayRange.get(row,1).getStringValue());
        ParaObjCode.add(displayRange.get(row,3).getStringValue());
        ParaProdMatrixId.add(displayRange.get(row,5).getStringValue());
        ParaProdChannelId.add(displayRange.get(row,7).getStringValue());
        ParaProdSalesGroupId.add(displayRange.get(row,9).getStringValue());
        ParaCustGroup.add(displayRange.get(row,11).getStringValue());
        ParaSlsThroughId.add(displayRange.get(row,13).getStringValue());
        Active.add(displayRange.get(row,14).getIntValue());
    }
    List<Object[]> ls = new ArrayList<Object[]>();
    for(int i=0;i<ParaObjGroup.size();i++){
        ls.add(new Object[]{ParaObjGroup.get(i),ParaObjCode.get(i),ParaProdMatrixId.get(i),ParaProdChannelId.get(i),ParaProdSalesGroupId.get(i),ParaCustGroup.get(i),ParaSlsThroughId.get(i),Active.get(i)});
    }
    lovService.coba(ls);

And then send Variable ls as parameter input in method coba :

@ServiceLog(schema = ConstantaVariable.DBDefinition_Var.PARAMS_DB_SCHEMA, sp = ConstantaVariable.PARAMSProcedure_VAR.PR_SP_FAHMI)
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class,SQLException.class})
public void coba(List<Object[]> lo){
    Map<String, Object> mapInputParameter = new LinkedHashMap<String, Object>();
    mapInputParameter.put("P_T_TABLE_UPLD_EXCEL", lo);
    ParamsService.getService().executeSPForInsertData(null,ConstantaVariable.PARAMSProcedure_VAR.PR_SP_FAHMI,mapInputParameter);
}

And code below is method to execute Stored Procedure. I want data in ls variable became inputParameter

@Autowired
DataSource paramsDataSourceBean;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor ={SQLException.class,Exception.class})
public void executeSPForInsertData(DataSource ds,String procedureName,Map<String, Object> inputParameter){

    SimpleJdbcCall jdbcCall = new SimpleJdbcCall(paramsDataSourceBean).withProcedureName(procedureName);
    String[] path = procedureName.split(".");
    if (path.length >= 2) {

        jdbcCall.withSchemaName(path[0]);
        jdbcCall.withCatalogName(path[1]);
        jdbcCall.withProcedureName(path[2]);
        jdbcCall.execute(inputParameter);
    }
}

And this is my Store Procedure

PROCEDURE PR_SP_FAHMI (P_T_TABLE_UPLD_EXCEL IN PARAMS.EXCEL) is 
  P_LOGID VARCHAR2(255);
BEGIN
BEGIN
  INSERT INTO PARAMS.EMPTY
  SELECT 
  C.PARA_OBJT_GROUP            ,
  C.PARA_OBJT_CODE             ,
  C.PARA_PROD_MATRIX_ID        ,
  C.PARA_PROD_CHANNEL_ID       ,
  C.PARA_PROD_SALES_GROUP_ID   ,
  C.PARA_CUST_GROUP            ,
  C.PARA_SLS_THROUGH_ID        ,
  C.ACTIVE                     
  FROM TABLE(P_T_TABLE_UPLD_EXCEL) C;
  EXCEPTION
            WHEN NO_DATA_FOUND THEN
                NULL;
            WHEN OTHERS THEN
                RAISE_APPLICATION_ERROR(-20001, 'ERROR-' || SQLERRM);
        END;
END PR_SP_FAHMI;

After i run, there are nothing happen and no error.

来源:https://stackoverflow.com/questions/61413672/how-to-passing-list-data-variable-to-store-procedure-and-execute-the-store-proce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!