use of org.eclipse.persistence.internal.helper.DatabaseType in project eclipselink by eclipse-ee4j.
the class PLSQLStoredProcedureCall method addNamedArgument.
/**
* PUBLIC:
* Add a named IN argument to the stored procedure. The databaseType parameter classifies the
* parameter (JDBCType vs. OraclePLSQLType, simple vs. complex). The extra scale and precision
* parameters indicates that this parameter, when used in an Anonymous PL/SQL block, requires
* scale and precision specification
*/
public void addNamedArgument(String procedureParameterName, DatabaseType databaseType, int precision, int scale) {
DatabaseType dt = databaseType.isComplexDatabaseType() ? ((ComplexDatabaseType) databaseType).clone() : databaseType;
arguments.add(new PLSQLargument(procedureParameterName, originalIndex++, IN, dt, precision, scale));
}
use of org.eclipse.persistence.internal.helper.DatabaseType in project eclipselink by eclipse-ee4j.
the class PLSQLParameterMetadata method process.
/**
* INTERNAL:
*/
public void process(PLSQLStoredProcedureCall call, boolean functionReturn) {
// Process the procedure parameter name, defaults to the
// argument field name.
// TODO: Log a message when defaulting.
String procedureParameterName = m_name;
if (m_name == null || m_name.equals("")) {
procedureParameterName = m_queryParameter;
}
if ((m_optional != null) && m_optional) {
call.addOptionalArgument(procedureParameterName);
}
DatabaseType type = getDatabaseTypeEnum(getDatabaseType());
// Process the parameter direction
if (functionReturn) {
// check for cursor return type
if (Direction.OUT_CURSOR.name().equals(m_direction)) {
// the constructor by default adds a RETURN argument, so remove it
call.getArguments().remove(0);
call.useNamedCursorOutputAsResultSet(Direction.OUT_CURSOR.name(), type);
} else {
if (getLength() != null) {
((PLSQLStoredFunctionCall) call).setResult(type, getLength());
} else if (getPrecision() != null) {
((PLSQLStoredFunctionCall) call).setResult(type, getPrecision(), getScale());
} else {
((PLSQLStoredFunctionCall) call).setResult(type);
}
}
} else if (m_direction == null || m_direction.equals(Direction.IN.name())) {
// TODO: Log a defaulting message if m_direction is null.
if (getLength() != null) {
call.addNamedArgument(procedureParameterName, type, getLength());
} else if (getPrecision() != null) {
call.addNamedArgument(procedureParameterName, type, getPrecision(), getScale());
} else {
call.addNamedArgument(procedureParameterName, type);
}
} else if (m_direction.equals(Direction.OUT.name())) {
if (getLength() != null) {
call.addNamedOutputArgument(procedureParameterName, type, getLength());
} else if (getPrecision() != null) {
call.addNamedOutputArgument(procedureParameterName, type, getPrecision(), getScale());
} else {
call.addNamedOutputArgument(procedureParameterName, type);
}
} else if (m_direction.equals(Direction.IN_OUT.name())) {
if (getLength() != null) {
call.addNamedInOutputArgument(procedureParameterName, type, getLength());
} else if (getPrecision() != null) {
call.addNamedInOutputArgument(procedureParameterName, type, getPrecision(), getScale());
} else {
call.addNamedInOutputArgument(procedureParameterName, type);
}
} else if (m_direction.equals(Direction.OUT_CURSOR.name())) {
boolean multipleCursors = false;
if (call.getParameterTypes().contains(DatasourceCall.OUT_CURSOR)) {
multipleCursors = true;
}
call.useNamedCursorOutputAsResultSet(procedureParameterName, type);
// There are multiple cursor output parameters, then do not use the cursor as the result set.
if (multipleCursors) {
call.setIsCursorOutputProcedure(false);
}
}
}
Aggregations