sqlparser/select.cpp
// ORDER BY clause in SELECT statement
ORDER BY clause in SELECT statement
ORDER BY clause in SELECT statement
bool SqlParser::ParseSelectOrderBy(Token **order_out)
{
	Token *order = GetNextWordToken("ORDER", L"ORDER", 5);
	if(order == NULL)
		return false;
	Token *by = GetNextWordToken("BY", L"BY", 2);
	if(by == NULL)
		return false;
	while(true)
	{
		Token *exp = GetNextToken();
		if(exp == NULL)
			break;
		ParseExpression(exp);
		Token *next = GetNextToken();
		if(next == NULL)
			break;
		if(next->Compare("ASC", L"ASC", 3) == true || next->Compare("DESC", L"DESC", 4) == true)
			next = GetNextToken();
		if(Token::Compare(next, ',', L',') == false)
		{
			PushBack(next);
			break;
		}
	}
	if(order_out != NULL)
		*order_out = order;
	return true;
}
bool SqlParser :: ParseSelectOrderBy ( Token * * order_out ) { Token * order = GetNextWordToken ( " " , L" " , 5 ) ; if ( order == NULL ) return false ; Token * by = GetNextWordToken ( " " , L" " , 2 ) ; if ( by == NULL ) return false ; while ( true ) { Token * exp = GetNextToken ( ) ; if ( exp == NULL ) break ; ParseExpression ( exp ) ; Token * next = GetNextToken ( ) ; if ( next == NULL ) break ; if ( next -> Compare ( " " , L" " , 3 ) == true || next -> Compare ( " " , L" " , 4 ) == true ) next = GetNextToken ( ) ; if ( Token :: Compare ( next , ' ' , L' ' ) == false ) { PushBack ( next ) ; break ; } } if ( order_out != NULL ) * order_out = order ; return true ; }
ORDER BY clause in SELECT statement
ORDER BY clause in SELECT statement
// Parse order expressions // An ORDER expression  // ASC or DESC // Must be comma