sqlparser/select.cpp
// UNION, UNION ALL, EXCEPT and MINUS operators
UNION, UNION ALL, EXCEPT and MINUS operators
UNION UNION ALL EXCEPT and MINUS operators
bool SqlParser::ParseSelectSetOperator(int block_scope, int )
{
	bool exists = false;
	while(true)
	{
		Token *op = GetNextToken();
		if(op == NULL)
			break;
		if(op->Compare("UNION", L"UNION", 5) == true)
		{
			 (void) GetNextWordToken("ALL", L"ALL", 3);
			exists = true;
			break;
		}
		else
		if(op->Compare("EXCEPT", L"EXCEPT", 6) == true)
		{
			if(_target == SQL_ORACLE)
				Token::Change(op, "MINUS", L"MINUS", 5);
			exists = true;
			break;
		}
		else
		if(op->Compare("MINUS", L"MINUS", 5) == true)
		{
			exists = true;
			break;
		}
		PushBack(op);
		break;
	}
	if(exists == true)
	{
		Token *open = GetNextCharToken('(', L'(');
		if(open != NULL)
		{
			ParseSubSelect(open, SQL_SEL_SET_UNION);
			 (void) GetNextCharToken(')', L')');
		}
		else
		{
			Token *select = GetNextWordToken("SELECT", L"SELECT", 6);
			if(select != NULL)
				ParseSelectStatement(select, block_scope, SQL_SEL_SET_UNION, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 
		}
	}
	return exists;
}
bool SqlParser :: ParseSelectSetOperator ( int block_scope , int ) { bool exists = false ; while ( true ) { Token * op = GetNextToken ( ) ; if ( op == NULL ) break ; if ( op -> Compare ( " " , L" " , 5 ) == true ) { ( void ) GetNextWordToken ( " " , L" " , 3 ) ; exists = true ; break ; } else if ( op -> Compare ( " " , L" " , 6 ) == true ) { if ( _target == SQL_ORACLE ) Token :: Change ( op , " " , L" " , 5 ) ; exists = true ; break ; } else if ( op -> Compare ( " " , L" " , 5 ) == true ) { exists = true ; break ; } PushBack ( op ) ; break ; } if ( exists == true ) { Token * open = GetNextCharToken ( ' ' , L' ' ) ; if ( open != NULL ) { ParseSubSelect ( open , SQL_SEL_SET_UNION ) ; ( void ) GetNextCharToken ( ' ' , L' ' ) ; } else { Token * select = GetNextWordToken ( " " , L" " , 6 ) ; if ( select != NULL ) ParseSelectStatement ( select , block_scope , SQL_SEL_SET_UNION , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL ) ; } } return exists ; }
UNION, UNION ALL, EXCEPT and MINUS operators
UNION UNION ALL EXCEPT and MINUS operators
/*select_scope*/ // UNION and UNION ALL /*Token *all */ // EXCEPT in SQL Server, DB2 // MINUS in Oracle // MINUS in Oracle // If a set operator exists next must a SELECT statement // SELECT or (SELECT ...) can be specified /*Token *close */