StoredProcedureCall call = new StoredProcedureCall(); call.setProcedureName("test"); call.addNamedArgument("p_year"); call.addNamedArgument("p_rel"); call.addNamedOutputArgument("p_data"); call.useNamedCursorOutputAsResultSet("p_resset"); @SuppressWarnings("rawtypes") List result= (List) s.executeQuery(query, args); DatabaseRecord record = (DatabaseRecord)results.get(0); String data = (String) record.get("p_data");
/** * PUBLIC: * Define the inoutput argument to the stored procedure and the field/argument name to be substitute for it on the way in and out. * The procedureParameterName is the name of the procedure argument expected. * The argumentFieldName is the field or argument name to be used to pass to the procedure and * is the result of the output row. */ public void addNamedInOutputArgument(String procedureParameterName, String argumentFieldName) { addNamedInOutputArgument(procedureParameterName, argumentFieldName, argumentFieldName, null); }
/** * PUBLIC: * Used for Oracle result sets through procedures. * This can only be used if the arguments are not named but ordered. */ public void useNamedCursorOutputAsResultSet(String argumentName) { useCursorOutputResultSet(argumentName, argumentName); // Store the cursor ordinal position after you add it. setCursorOrdinalPosition(argumentName, getParameters().size()); }
/** * PUBLIC: * Define the argument to the stored procedure and the value to be substitute for it. * The procedureParameterName is the name of the procedure argument expected. * The argumentValue is the value of the argument to be used to pass to the procedure. */ public void addNamedArgumentValue(String procedureParameterName, Object argumentValue) { getProcedureArgumentNames().add(procedureParameterName); appendIn(argumentValue); }
boolean outParameterFound = false;; tailWriter.write(call.getProcedureName()); tailWriter.write("("); int indexFirst = call.getFirstParameterIndexForCallString(); int size = call.getParameters().size(); String nextBindString = "?"; String name = call.getProcedureArgumentNames().get(index); Object parameter = call.getParameters().get(index); Integer parameterType = call.getParameterTypes().get(index); if (!call.hasOptionalArguments() || !call.getOptionalArguments().contains(parameter) || (row.get(parameter) != null)) { if (!call.isOutputParameterType(parameterType)) { tailWriter.write(nextBindString); nextBindString = ", ?"; if (outParameterFound) { throw ValidationException.multipleOutParamsNotSupported(Helper.getShortClassName(this), call.getProcedureName());
spCall.setProcedureName(getName()); } else { spCall.setProcedureName(queryOperation.getName()); spCall.addNamedInOutputArgument(argName, p.getName()); } else { spCall.addNamedArgument(argName, p.getName()); (spCall.isStoredFunctionCall() && !isCursorType(xrService, resultType))) { setSingleResult(xrService, spCall, resultType); if (queryOperation.getResult().isJdbcTypeSet()) { spCall.addNamedOutputArgument(arg.getName(), arg.getName(), arg.getJdbcType(), getTypeNameForJDBCType(arg.getJdbcType())); } else { spCall.addNamedOutputArgument(arg.getName()); if (spCall.isStoredFunctionCall() && isCursorType(xrService, resultType)) { spCall.setIsCursorOutputProcedure(true); spCall.getParameters().remove(0); spCall.getParameters().add(0, new DatabaseField(CURSOR_STR)); } else if (getOutArguments().isEmpty()) { spCall.setReturnsResultSet(true); } else { for (ProcedureOutputArgument arg : getOutArguments()) { spCall.useNamedCursorOutputAsResultSet(arg.getName()); } else { if (arg.isJdbcTypeSet()) {
if (hasType()) { if (callByIndex) { call.addUnamedArgument(m_queryParameter, getJavaClass(m_type)); } else { if (hasJdbcType() && hasJdbcTypeName()) { OracleArrayTypeMetadata aType = null; if (hasTypeName() && (aType = getArrayTypeMetadata(m_typeName)) != null) { call.addNamedArgument(m_name, m_queryParameter, m_jdbcType, m_jdbcTypeName, getJavaClass(m_type), buildNestedField(aType)); } else { call.addNamedArgument(m_name, m_queryParameter, m_jdbcType, m_jdbcTypeName, getJavaClass(m_type)); call.addNamedArgument(m_name, m_queryParameter, getJavaClass(m_type)); call.addUnamedArgument(m_queryParameter, m_jdbcType, m_jdbcTypeName); } else { call.addNamedArgument(m_name, m_queryParameter, m_jdbcType, m_jdbcTypeName); call.addUnamedArgument(m_queryParameter, m_jdbcType); } else { call.addNamedArgument(m_name, m_queryParameter, m_jdbcType); call.addUnamedArgument(m_queryParameter); } else { call.addNamedArgument(m_name, m_queryParameter); if (hasType()) { if (callByIndex) { call.addUnamedOutputArgument(m_queryParameter, getJavaClass(m_type)); } else {
call.addNamedArgument(parameterName, parameterName, type); } else if (mode.equals(ParameterMode.OUT)) { call.addNamedOutputArgument(parameterName, parameterName, type); call.setCursorOrdinalPosition(parameterName, call.getParameters().size()); } else if (mode.equals(ParameterMode.INOUT)) { call.addNamedInOutputArgument(parameterName, parameterName, parameterName, type); call.setCursorOrdinalPosition(parameterName, call.getParameters().size()); } else if (mode.equals(ParameterMode.REF_CURSOR)) { call.useNamedCursorOutputAsResultSet(parameterName);
writer.write(call.getCallHeader(this)); writer.write(call.getProcedureName()); if (requiresProcedureCallBrackets()) { writer.write("("); int indexFirst = call.getFirstParameterIndexForCallString(); for (int index = indexFirst; index < call.getParameters().size(); index++) { String name = (String)call.getProcedureArgumentNames().elementAt(index); Integer parameterType = (Integer)call.getParameterTypes().elementAt(index); if (name != null && shouldPrintStoredProcedureArgumentNameInCall()) { writer.write(getProcedureArgumentString()); if (call.isOutputParameterType(parameterType)) { if (requiresProcedureCallOuputToken()) { writer.write(" "); if ((index + 1) < call.getParameters().size()) { writer.write(", "); call.setProcedureArgumentNames(null);
@Override public Object getAttributeValueFromObject(Object anObject) throws DescriptorException { StoredProcedureCall spc = (StoredProcedureCall)anObject; List parameterTypes = spc.getParameterTypes(); List parameters = spc.getParameters(); List procedureArgumentNames = spc.getProcedureArgumentNames(); List storedProcedureArguments = new Vector(); for (int i = spc.getFirstParameterIndexForCallString(); i < parameterTypes.size(); i++) { StoredProcedureArgument spa = null; Integer direction = (Integer)parameterTypes.get(i);
/** * PUBLIC: * Define the inoutput argument to the stored procedure and the field/argument name to be substitute for it on the way in and out. * The procedureParameterAndArgumentFieldName is the name of the procedure argument expected, * the field or argument name to be used to pass to the procedure and, * the field or argument name to be used is the result of the output row. */ public void addNamedInOutputArgument(String procedureParameterAndArgumentFieldName) { getProcedureArgumentNames().add(procedureParameterAndArgumentFieldName); appendInOut(new DatabaseField(procedureParameterAndArgumentFieldName)); }
/** * INTERNAL: * Add the unnamed output cursor to return the result. */ protected void useCursorOutputResultSet(String argumentName, String outputFieldName) { // Set the isCursorOutputProcedure first based on the outputCursor list. // Should be true if there is one and only one, once a second is added, // the flag must be false. setIsCursorOutputProcedure(!hasOutputCursors()); setIsMultipleCursorOutputProcedure(hasOutputCursors()); getProcedureArgumentNames().add(argumentName); appendOutCursor(new DatabaseField(outputFieldName)); }
super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), type.getTypeName()); } else { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode()); if (inArg.inIndex != MIN_VALUE) { if (complexType.isStruct()) { super.addNamedArgument(inArg.name, inArg.name, complexType.getSqlCode(), complexType.getTypeName()); } else if (complexType.isArray()) { DatabaseType nestedType = ((OracleArrayType) complexType).getNestedType(); field.setSqlType(nestedType.getSqlCode()); field.setSqlTypeName(nestedType.getTypeName()); super.addNamedArgument(inArg.name, inArg.name, complexType.getSqlCode(), complexType.getTypeName(), field); } else { super.addNamedArgument(inArg.name, inArg.name, complexType.getSqlCode(), complexType.getTypeName()); super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType(), field); } else { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType()); super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType()); super.useNamedCursorOutputAsResultSet(outArg.name); } else { DatabaseType type = outArg.databaseType; super.addNamedOutputArgument(outArg.name, outArg.name, type.getConversionCode(), type.getTypeName()); } else { super.addNamedOutputArgument(outArg.name, outArg.name, type.getConversionCode());
/** * PUBLIC: * Define the output argument to the stored procedure and the field/argument name to be substitute for it. * The procedureParameterAndArgumentFieldName is the name of the procedure argument expected, * and is the field or argument name to be used to pass to the procedure. * These names are assumed to be the same, if not this method can be called with two arguments. */ public void addNamedOutputArgument(String procedureParameterAndArgumentFieldName) { addNamedOutputArgument(procedureParameterAndArgumentFieldName, procedureParameterAndArgumentFieldName); }
/** * PUBLIC: * Used for Oracle result sets through procedures. * This can only be used if the arguments are not named but ordered. */ public void useNamedCursorOutputAsResultSet(String argumentName) { setIsCursorOutputProcedure(true); getProcedureArgumentNames().add(argumentName); appendOutCursor(new DatabaseField(argumentName)); }
protected void setSingleResult(XRServiceAdapter xrService, StoredProcedureCall spCall, QName resultType) { if (getOutArguments().size() == 1) { ProcedureArgument arg = getOutArguments().get(0); // check query's returnType or arg's returnType if (isCursorType(xrService, resultType) || ( arg instanceof ProcedureOutputArgument && isCursorType(xrService, ((ProcedureOutputArgument)arg).getResultType()))) { spCall.useNamedCursorOutputAsResultSet(arg.getName()); } else { spCall.addNamedOutputArgument(arg.getName()); } } }
int type = argument.direction; if ((type == StoredProcedureCall.IN) || (type == StoredProcedureCall.INOUT)) { if (call.hasOptionalArguments()) { query.addArgument(argument.name, Object.class, call.getOptionalArguments().contains(new DatabaseField(argument.name))); } else { query.addArgument(argument.name); for (int index = 0; index < call.getParameters().size(); index++) { int type = call.getParameterTypes().get(index); if ((type == StoredProcedureCall.IN) || (type == StoredProcedureCall.INOUT)) { Object value = call.getParameters().get(index); DatabaseField parameter = null; if (value instanceof Object[]) { parameter = (DatabaseField) ((Object[])value)[0]; } else { parameter = (DatabaseField)call.getParameters().get(index); if (call.hasOptionalArguments()) { query.addArgument(parameter.getName(), Object.class, call.getOptionalArguments().contains(parameter)); } else { query.addArgument(parameter.getName());
/** * PUBLIC: * Define the argument to the stored procedure and the field/argument name to be substitute for it. * The procedureParameterAndArgumentFieldName is the name of the procedure argument expected, * and is the field or argument name to be used to pass to the procedure. * These names are assumed to be the same, if not this method can be called with two arguments. */ public void addNamedArgument(String procedureParameterAndArgumentFieldName) { addNamedArgument(procedureParameterAndArgumentFieldName, procedureParameterAndArgumentFieldName); }
for (Object parameter : getCall().getParameters()) { Integer parameterType = getCall().getParameterTypes().get(index); String argumentName = getCall().getProcedureArgumentNames().get(index);
DatabaseType type = inArg.databaseType; if (!type.isComplexDatabaseType()) { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode()); super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType(), field); super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType()); super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType()); DatabaseType type = outArg.databaseType; if (!type.isComplexDatabaseType()) { super.addNamedOutputArgument(outArg.name, outArg.name, type.getConversionCode()); } else { ComplexDatabaseType complexType = (ComplexDatabaseType)type; super.addNamedOutputArgument(outArg.name, outArg.name, type.getConversionCode(), complexType.getCompatibleType(), complexType.getJavaType(), nestedField); } else { super.addNamedOutputArgument(outArg.name, outArg.name, type.getConversionCode(), complexType.getCompatibleType()); super.addNamedOutputArgument(outArg.name, outArg.name, type.getConversionCode(), complexType.getCompatibleType(), complexType.getJavaType()); } else { super.addNamedOutputArgument(outArg.name, outArg.name, type.getConversionCode());