/** * INTERNAL Generate portion of the Anonymous PL/SQL block that assigns fields at the beginning * of the BEGIN block (before invoking the target procedure). */ protected void buildBeginBlock(StringBuilder sb, List<PLSQLargument> arguments) { List<PLSQLargument> inArguments = getArguments(arguments, IN); inArguments.addAll(getArguments(arguments, INOUT)); for (PLSQLargument arg : inArguments) { arg.databaseType.buildBeginBlock(sb, arg, this); } }
/** * INTERNAL * Generate portion of the Anonymous PL/SQL block that declares the temporary variables * in the DECLARE section * * @param sb */ protected void buildDeclareBlock(StringBuilder sb) { List<PLSQLargument> inArguments = getArguments(arguments, IN); List<PLSQLargument> inOutArguments = getArguments(arguments, INOUT); inArguments.addAll(inOutArguments); List<PLSQLargument> outArguments = getArguments(arguments, OUT); for (PLSQLargument arg : inArguments) { arg.databaseType.buildInDeclare(sb, arg); } for (PLSQLargument arg : outArguments) { arg.databaseType.buildOutDeclare(sb, arg); } }
/** * INTERNAL Generate portion of the Anonymous PL/SQL block after the target procedures has been * invoked and OUT parameters must be handled. */ protected void buildOutAssignments(StringBuilder sb, List<PLSQLargument> arguments) { List<PLSQLargument> outArguments = getArguments(arguments, OUT); outArguments.addAll(getArguments(arguments, INOUT)); for (PLSQLargument arg : outArguments) { arg.databaseType.buildOutAssignment(sb, arg, this); } }
if (inArg.databaseType.isComplexDatabaseType() && (!((ComplexDatabaseType) inArg.databaseType).hasCompatibleType())) { expandedArguments.add(inArg); inArgsIter.remove(); newIndex = inArg.databaseType.computeInIndex(inArg, newIndex, inArgsIter); if (!type.isComplexDatabaseType()) { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), type.getTypeName()); } else { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode()); if (nestedType != null) { ObjectRelationalDatabaseField field = new ObjectRelationalDatabaseField(""); field.setSqlType(nestedType.getSqlCode()); field.setSqlTypeName(nestedType.getTypeName()); super.addNamedArgument(inArg.name, inArg.name, complexType.getSqlCode(), complexType.getTypeName(), field); } else { if (nestedType != null) { ObjectRelationalDatabaseField field = new ObjectRelationalDatabaseField(""); field.setSqlType(nestedType.getConversionCode()); if (nestedType.isComplexDatabaseType()) { field.setSqlTypeName(((ComplexDatabaseType) nestedType).getCompatibleType()); super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType(), field); } else { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType());
public PLSQLStoredFunctionCall(DatabaseType databaseType, int length, int scale) { super(); DatabaseType dt = databaseType.isComplexDatabaseType() ? ((ComplexDatabaseType)databaseType).clone() : databaseType; this.arguments.add(new PLSQLargument("RESULT", this.originalIndex++, OUT, dt, length, scale)); }
if (inArg.databaseType.isComplexDatabaseType() && (!((ComplexDatabaseType)inArg.databaseType).hasCompatibleType())) { expandedArguments.add(inArg); inArgsIter.remove(); newIndex = inArg.databaseType.computeInIndex(inArg, newIndex, inArgsIter); if (!type.isComplexDatabaseType()) { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode()); ObjectRelationalDatabaseField field = new ObjectRelationalDatabaseField(inArg.name); field.setSqlType(nestedType.getConversionCode()); if (nestedType.isComplexDatabaseType()) { field.setSqlTypeName(((ComplexDatabaseType)nestedType).getCompatibleType()); 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()); for (ListIterator<PLSQLargument> outArgsIter = outArguments.listIterator(); outArgsIter.hasNext();) { PLSQLargument outArg = outArgsIter.next(); newIndex = outArg.databaseType.computeOutIndex(outArg, newIndex, outArgsIter);
if ((databaseType == null) || !databaseType.isComplexDatabaseType() || databaseType.isJDBCType() || processed.contains(databaseType)) { return;
public void declareTarget(StringBuilder sb, PLSQLargument arg, DatabaseType databaseType) { sb.append(" "); sb.append(buildTarget(arg)); sb.append(" "); sb.append(databaseType.getTypeName()); }
/** * Translate the SQL procedure output row, into the row * expected by the PLSQL procedure. * This handles re-ordering parameters. */ @Override public AbstractRecord buildOutputRow(CallableStatement statement) throws SQLException { AbstractRecord outputRow = super.buildOutputRow(statement); if (!shouldBuildOutputRow) { outputRow.put("", 1); // fake-out Oracle executeUpdate rowCount, always 1 return outputRow; } // re-order elements in outputRow to conform to original indices Vector outputRowFields = outputRow.getFields(); Vector outputRowValues = outputRow.getValues(); DatabaseRecord newOutputRow = new DatabaseRecord(); List<PLSQLargument> outArguments = getArguments(arguments, OUT); outArguments.addAll(getArguments(arguments, INOUT)); Collections.sort(outArguments, new Comparator<PLSQLargument>() { public int compare(PLSQLargument o1, PLSQLargument o2) { return o1.originalIndex - o2.originalIndex; } }); for (PLSQLargument outArg : outArguments) { outArg.databaseType.buildOutputRow(outArg, outputRow, newOutputRow, outputRowFields, outputRowValues); } return newOutputRow; }
if (inArg.databaseType.isComplexDatabaseType() && (!((ComplexDatabaseType) inArg.databaseType).hasCompatibleType())) { expandedArguments.add(inArg); inArgsIter.remove(); newIndex = inArg.databaseType.computeInIndex(inArg, newIndex, inArgsIter); if (!type.isComplexDatabaseType()) { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), type.getTypeName()); } else { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode()); if (nestedType != null) { ObjectRelationalDatabaseField field = new ObjectRelationalDatabaseField(""); field.setSqlType(nestedType.getSqlCode()); field.setSqlTypeName(nestedType.getTypeName()); super.addNamedArgument(inArg.name, inArg.name, complexType.getSqlCode(), complexType.getTypeName(), field); } else { if (nestedType != null) { ObjectRelationalDatabaseField field = new ObjectRelationalDatabaseField(""); field.setSqlType(nestedType.getConversionCode()); if (nestedType.isComplexDatabaseType()) { field.setSqlTypeName(((ComplexDatabaseType) nestedType).getCompatibleType()); super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType(), field); } else { super.addNamedArgument(inArg.name, inArg.name, type.getConversionCode(), complexType.getCompatibleType());
/** * PUBLIC: Add a named IN OUT argument to the stored procedure. The databaseType parameter * classifies the parameter (JDBCType vs. OraclePLSQLType, simple vs. complex) */ public void addNamedInOutputArgument(String procedureParameterName, DatabaseType databaseType) { DatabaseType dt = databaseType.isComplexDatabaseType() ? ((ComplexDatabaseType)databaseType).clone() : databaseType; arguments.add(new PLSQLargument(procedureParameterName, originalIndex++, INOUT, dt)); }
/** * Wrap the type in a type wrapper to handle XML conversion. */ public static DatabaseTypeWrapper wrapType(DatabaseType databaseType) { if (databaseType.isJDBCType()) { return new JDBCTypeWrapper(databaseType); } else if (databaseType.isComplexDatabaseType()) { ComplexDatabaseType complexType = (ComplexDatabaseType)databaseType; if (complexType.isRecord()) { return new PLSQLRecordWrapper(databaseType); } else if (complexType.isCollection()) { return new PLSQLCollectionWrapper(databaseType); } } else { return new SimplePLSQLTypeWrapper(databaseType); } return null; } /**
public void declareTarget(StringBuilder sb, PLSQLargument arg, DatabaseType databaseType) { sb.append(" "); sb.append(buildTarget(arg)); sb.append(" "); sb.append(databaseType.getTypeName()); }
/** * Translate the SQL procedure output row, into the row * expected by the PLSQL procedure. * This handles re-ordering parameters. */ @Override public AbstractRecord buildOutputRow(CallableStatement statement, DatabaseAccessor accessor, AbstractSession session) throws SQLException { AbstractRecord outputRow = super.buildOutputRow(statement, accessor, session); if (!shouldBuildOutputRow) { outputRow.put("", 1); // fake-out Oracle executeUpdate rowCount, always 1 return outputRow; } // re-order elements in outputRow to conform to original indices Vector outputRowFields = outputRow.getFields(); Vector outputRowValues = outputRow.getValues(); DatabaseRecord newOutputRow = new DatabaseRecord(); List<PLSQLargument> outArguments = getArguments(arguments, OUT); outArguments.addAll(getArguments(arguments, INOUT)); Collections.sort(outArguments, new Comparator<PLSQLargument>() { public int compare(PLSQLargument o1, PLSQLargument o2) { return o1.originalIndex - o2.originalIndex; } }); for (PLSQLargument outArg : outArguments) { outArg.databaseType.buildOutputRow(outArg, outputRow, newOutputRow, outputRowFields, outputRowValues); } return newOutputRow; }
public PLSQLStoredFunctionCall(DatabaseType databaseType, int length, int scale) { super(); DatabaseType dt = databaseType.isComplexDatabaseType() ? ((ComplexDatabaseType)databaseType).clone() : databaseType; this.arguments.add(new PLSQLargument("RESULT", this.originalIndex++, OUT, dt, length, scale)); }
DatabaseType databaseType, Set<DatabaseType> processed) { if ((databaseType == null) || !databaseType.isComplexDatabaseType() || databaseType.isJDBCType() || argument.cursorOutput || processed.contains(databaseType)) {
/** * INTERNAL * Generate portion of the Anonymous PL/SQL block that declares the temporary variables * in the DECLARE section. */ protected void buildDeclareBlock(StringBuilder sb, List<PLSQLargument> arguments) { List<PLSQLargument> inArguments = getArguments(arguments, IN); List<PLSQLargument> inOutArguments = getArguments(arguments, INOUT); inArguments.addAll(inOutArguments); List<PLSQLargument> outArguments = getArguments(arguments, OUT); Collections.sort(inArguments, new InArgComparer()); for (PLSQLargument arg : inArguments) { arg.databaseType.buildInDeclare(sb, arg); } Collections.sort(outArguments, new OutArgComparer()); for (PLSQLargument arg : outArguments) { arg.databaseType.buildOutDeclare(sb, arg); } }
public void declareTarget(StringBuilder sb, PLSQLargument arg, DatabaseType databaseType) { sb.append(" "); sb.append(buildTarget(arg)); sb.append(" "); sb.append(databaseType.getTypeName()); }
/** * INTERNAL Generate portion of the Anonymous PL/SQL block after the target procedures has been * invoked and OUT parameters must be handled. */ protected void buildOutAssignments(StringBuilder sb, List<PLSQLargument> arguments) { List<PLSQLargument> outArguments = getArguments(arguments, OUT); outArguments.addAll(getArguments(arguments, INOUT)); for (PLSQLargument arg : outArguments) { arg.databaseType.buildOutAssignment(sb, arg, this); } }
/** * INTERNAL Generate portion of the Anonymous PL/SQL block that assigns fields at the beginning * of the BEGIN block (before invoking the target procedure). */ protected void buildBeginBlock(StringBuilder sb, List<PLSQLargument> arguments) { List<PLSQLargument> inArguments = getArguments(arguments, IN); inArguments.addAll(getArguments(arguments, INOUT)); for (PLSQLargument arg : inArguments) { arg.databaseType.buildBeginBlock(sb, arg, this); } }