protected void postHookExecutionCommand(StringBuilder buffer) {}
@Override
public String buildExecutionCommand(MethodExecutionInput executionInput) throws SQLException {
DBArgument returnArgument = getReturnArgument();
StringBuilder buffer = new StringBuilder();
buffer.append("declare\n");
// variable declarations
List<DBArgument> arguments = getArguments();
for (DBArgument argument : arguments) {
DBDataType dataType = argument.getDataType();
if (dataType.isDeclared()) {
buffer.append(" ");
appendVariableName(buffer, argument);
buffer.append(" ").append(dataType.getDeclaredType().getQualifiedName()).append(";\n");
} else if (isBoolean(dataType)) {
appendVariableName(buffer, argument);
buffer.append(" boolean;\n");
}
}
buffer.append("begin\n");
preHookExecutionCommand(buffer);
// input variable initialization
for (DBArgument argument : arguments) {
DBDataType dataType = argument.getDataType();
if (argument.isInput()) {
if (dataType.isDeclared()) {
List<DBTypeAttribute> attributes = dataType.getDeclaredType().getAttributes();
for (DBTypeAttribute attribute : attributes) {
buffer.append(" ");
appendVariableName(buffer, argument);
buffer.append(".").append(attribute.getName()).append(" := ?;\n");
}
} else if(isBoolean(dataType)) {
String stringValue = parseBoolean(argument.getName(), executionInput.getInputValue(argument));
buffer.append(" ");
appendVariableName(buffer, argument);
buffer.append(" := ").append(stringValue).append(";\n");
}
}
}
// method call
buffer.append("\n ");
if (returnArgument != null) {
DBDataType dataType = returnArgument.getDataType();
if (dataType.isDeclared() || isBoolean(dataType))
appendVariableName(buffer, returnArgument); else
buffer.append("?");
buffer.append(" := ");