sqlparser/language.cpp
// Add @ for SQL Server, Sybase variable or parameter
Add @ for SQL Server, Sybase variable or parameter
Add @ for SQL Server Sybase variable or parameter
bool SqlParser::ConvertToTsqlVariable(Token *name)
{
	if(name == NULL)
		return false;
	const char *cur = name->str;
	if(cur == NULL || *cur == '@')
		return false;
	char *ident = new char[name->len + 2];
	*ident = '@';
	size_t len = name->len + 1;
	size_t pos = 1;
	for(size_t i = 0; i < name->len; i++)
	{
		if(i == 0 && cur[i] == '#')
			len--;
		else
		{
			ident[pos] = cur[i];
			pos++;
		}
	}
	ident[len] = 0;
	name->t_str = ident;
	name->t_len = len;
	return true;
}
bool SqlParser :: ConvertToTsqlVariable ( Token * name ) { if ( name == NULL ) return false ; const char * cur = name -> str ; if ( cur == NULL || * cur == ' ' ) return false ; char * ident = new char [ name -> len + 2 ] ; * ident = ' ' ; size_t len = name -> len + 1 ; size_t pos = 1 ; for ( size_t i = 0 ; i < name -> len ; i ++ ) { if ( i == 0 && cur [ i ] == ' ' ) len -- ; else { ident [ pos ] = cur [ i ] ; pos ++ ; } } ident [ len ] = 0 ; name -> t_str = ident ; name -> t_len = len ; return true ; }
Add @ for SQL Server, Sybase variable or parameter
Add @ for SQL Server Sybase variable or parameter
// Check if there is already starting @ // Allocate space for @ and terminating 0 // Copy content after @ // Check for a special character to be replaced by @ at first position rather than appended