/** Creates a OpTypes.SEQUENCE expression */ ExpressionColumn(NumberSequence sequence, int opType) { super(opType); this.sequence = sequence; dataType = sequence.getDataType(); }
public HsqlList resolveColumnReferences( Session session, RangeVariable[] rangeVarArray, int rangeCount, HsqlList unresolvedSet, boolean acceptsSequences) { switch (opType) { case OpTypes.SEQUENCE: if (!acceptsSequences) { throw Error.error(ErrorCode.X_42598); } break; case OpTypes.ROWNUM: case OpTypes.MULTICOLUMN: case OpTypes.DYNAMIC_PARAM: case OpTypes.ASTERISK: case OpTypes.SIMPLE_COLUMN: case OpTypes.COALESCE: case OpTypes.DIAGNOSTICS_VARIABLE: break; case OpTypes.COLUMN: case OpTypes.PARAMETER: case OpTypes.VARIABLE: { boolean resolved = false; boolean tableQualified = tableName != null; if (rangeVariable != null) { return unresolvedSet; } for (int i = 0; i < rangeCount; i++) { RangeVariable rangeVar = rangeVarArray[i]; if (rangeVar == null) { continue; } if (resolved) { if (session.database.sqlEnforceRefs) { if (resolvesDuplicateColumnReference(rangeVar)) { String message = getColumnName(); if (alias != null) { StringBuffer sb = new StringBuffer(message); sb.append(' ').append(Tokens.T_AS).append(' ').append(alias.getStatementName()); message = sb.toString(); } throw Error.error(ErrorCode.X_42580, message); } } } else { if (resolveColumnReference(rangeVar)) { if (tableQualified) { return unresolvedSet; } resolved = true; continue; } } } if (resolved) { return unresolvedSet; } if (session.database.sqlSyntaxOra) { if (acceptsSequences && tableName != null) { if (Tokens.T_CURRVAL.equals(columnName)) { NumberSequence seq = session.database.schemaManager.getSequence( tableName, session.getSchemaName(schema), false); if (seq != null) { opType = OpTypes.SEQUENCE_CURRENT; dataType = seq.getDataType(); sequence = seq; schema = null; tableName = null; columnName = null; resolved = true; } } else if (Tokens.T_NEXTVAL.equals(columnName)) { NumberSequence seq = session.database.schemaManager.getSequence( tableName, session.getSchemaName(schema), false); if (seq != null) { opType = OpTypes.SEQUENCE; dataType = seq.getDataType(); sequence = seq; schema = null; tableName = null; columnName = null; resolved = true; } } } } if (resolved) { return unresolvedSet; } if (unresolvedSet == null) { unresolvedSet = new ArrayListIdentity(); } unresolvedSet.add(this); } } return unresolvedSet; }