4 Replies Latest reply on Jul 19, 2013 1:37 AM by Devesh Mishra

    How to create a stored procedure to take varargs as IN parameters using java code (no DDL)

    Devesh Mishra Newbie

      I need to create a stored procedure which takes a parameter of variable length. Following is what I am doing but to not avail.

       

       

              final Procedure saveUsersProc = metadataFactory.addProcedure("save_user_details");
              
              ProcedureParameter param = new ProcedureParameter();
              param.setName("userInfo");
              param.setType(ProcedureParameter.Type.In);
              param.setDatatype(metadataFactory.getDataTypes().get(TypeFacility.RUNTIME_NAMES.STRING));
              param.setProcedure(saveUsersProc);
              
              saveUsersProc.getParameters().add(param);
              param.setPosition(saveUsersProc.getParameters().size()); 
              param.setVarArg(true);
              
              
              metadataFactory.addProcedureResultSetColumn("status",
                           TypeFacility.RUNTIME_NAMES.STRING,
                           saveUsersProc);
      

       

       

      If I execute CALL save_user_details('a','b'), I get error saying CALL save_user_details('a','b'), TEIID30140 Incorrect number of parameters specified on the stored procedure save_user_details - expected 1 but got 2

       

      Thanks in advance for help.