Search in sources :

Example 1 with ProcedureParameter

use of com.actiontech.dble.route.ProcedureParameter in project dble by actiontech.

the class AbstractRouteStrategy method parseProcedureForCall.

private void parseProcedureForCall(Procedure procedure, String query, SQLCallStatement statement) {
    SQLCallStatement sqlCallStatement = statement;
    procedure.setName(sqlCallStatement.getProcedureName().getSimpleName());
    List<SQLExpr> parameterList = sqlCallStatement.getParameters();
    for (int i1 = 0; i1 < parameterList.size(); i1++) {
        SQLExpr sqlExpr = parameterList.get(i1);
        String pName = sqlExpr.toString();
        ProcedureParameter parameter = new ProcedureParameter();
        parameter.setIndex(i1 + 1);
        parameter.setName(pName);
        parameter.setParameterType(ProcedureParameter.IN);
        if (pName.startsWith("@")) {
            procedure.getParameterMap().put(pName, parameter);
        } else {
            procedure.getParameterMap().put(String.valueOf(i1 + 1), parameter);
        }
    }
    procedure.setCallSql(query);
}
Also used : ProcedureParameter(com.actiontech.dble.route.ProcedureParameter) SQLCallStatement(com.alibaba.druid.sql.ast.statement.SQLCallStatement) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Aggregations

ProcedureParameter (com.actiontech.dble.route.ProcedureParameter)1 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)1 SQLCallStatement (com.alibaba.druid.sql.ast.statement.SQLCallStatement)1