コード例 #1
0
ファイル: sqlserver.cpp プロジェクト: digvijaykatoch/sqlines
// 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;

	// Parse parameters
	// Sybase ASE does not use () around parameters
	while(true)
	{
		Token *next = GetNextToken();

		if(next == NULL)
			break;

		// 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
		if(params == 0 && !IsValidAlias(next))
		{
			PushBack(next);
			break;
		}

		ConvertIdentifier(next, SQL_IDENT_VAR);

		// OUTPUT qualifier can be specified for parameter in Sybase ASE
		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++;
	}

	// When there are no parameters MySQL, MariaDB allow as CALL name() and CALL name
	if(params > 0)
	{		
		if(Target(SQL_MARIADB, SQL_MYSQL))
		{
			APPEND_NOFMT(name, "(");
			APPEND_NOFMT(GetLastToken(), ")");
		}
	}
}
コード例 #2
0
ファイル: sqlparser.cpp プロジェクト: erpframework/sqlines
// Get next token that must be identifier
Token* SqlParser::GetNextIdentToken(int expected_type, int scope)
{
	Token *token = GetNextToken();

	if(token == NULL)
		return NULL;

	// If it is a word token, convert identifier
	if(token->type == TOKEN_WORD || token->type == TOKEN_IDENT)
		ConvertIdentifier(token, expected_type, scope);

	// Must not be a single char token (non-alpabetical)
	if(token->chr != 0 || token->wchr != 0)
	{
		PushBack(token);
		return NULL;
	}

	return token;
}