sqlparser/sqlserver.cpp
// SQL Server, Sybase ASE EXEC procedure statement
SQL Server, Sybase ASE EXEC procedure statement
SQL Server Sybase ASE EXEC procedure statement
void SqlParser::ParseSqlServerExecProcedure(Token *execute, Token *name)
{
	if(execute == NULL || name == NULL)
		return;
	ConvertIdentifier(name, SQL_IDENT_OBJECT);
	if(Target(SQL_MARIADB, SQL_MYSQL))
		TOKEN_CHANGE(execute, "CALL");
	int params = 0;
	while(true)
	{
		Token *next = GetNextToken();
		if(next == NULL)
			break;
		if(params == 0 && !IsValidAlias(next))
		{
			PushBack(next);
			break;
		}
		ConvertIdentifier(next, SQL_IDENT_VAR);
		Token *output = GetNext("OUTPUT", L"OUTPUT", 6);
		if(output != NULL && Target(SQL_MARIADB, SQL_MYSQL))
			Token::Remove(output);
		Token *comma = GetNext(',', L',');
		if(comma == NULL)
			break;
		params++;
	}
	if(params > 0)
	{		
		if(Target(SQL_MARIADB, SQL_MYSQL))
		{
			APPEND_NOFMT(name, "(");
			APPEND_NOFMT(GetLastToken(), ")");
		}
	}
}
void SqlParser :: ParseSqlServerExecProcedure ( Token * execute , Token * name ) { if ( execute == NULL || name == NULL ) return ; ConvertIdentifier ( name , SQL_IDENT_OBJECT ) ; if ( Target ( SQL_MARIADB , SQL_MYSQL ) ) TOKEN_CHANGE ( execute , " " ) ; int params = 0 ; while ( true ) { Token * next = GetNextToken ( ) ; if ( next == NULL ) break ; if ( params == 0 && ! IsValidAlias ( next ) ) { PushBack ( next ) ; break ; } ConvertIdentifier ( next , SQL_IDENT_VAR ) ; Token * output = GetNext ( " " , L" " , 6 ) ; if ( output != NULL && Target ( SQL_MARIADB , SQL_MYSQL ) ) Token :: Remove ( output ) ; Token * comma = GetNext ( ' ' , L' ' ) ; if ( comma == NULL ) break ; params ++ ; } if ( params > 0 ) { if ( Target ( SQL_MARIADB , SQL_MYSQL ) ) { APPEND_NOFMT ( name , " " ) ; APPEND_NOFMT ( GetLastToken ( ) , " " ) ; } } }
SQL Server, Sybase ASE EXEC procedure statement
SQL Server Sybase ASE EXEC procedure statement
// Parse parameters // Sybase ASE does not use () around parameters // If there are no params, we can have conflict with next statement as there may be no delimiters in Transact-SQL // If there is at least one parameter, no conflict is possible for subsequent params as comma defines whether it exists or not // OUTPUT qualifier can be specified for parameter in Sybase ASE // When there are no parameters MySQL, MariaDB allow as CALL name() and CALL name