sqlparser/statements.cpp
// DECLARE LOCAL TEMPORARY TABLE in Sybase ASA
DECLARE LOCAL TEMPORARY TABLE in Sybase ASA
DECLARE LOCAL TEMPORARY TABLE in Sybase ASA
bool SqlParser::ParseDeclareLocalTemporaryTable(Token *declare, Token *local)
{
	if(declare == NULL || local == NULL)
		return false;
	if(local->Compare("LOCAL", L"LOCAL", 5) == false)
		return false;
	Token *temporary = GetNextWordToken("TEMPORARY", L"TEMPORARY", 9);
	if(temporary == NULL)
		return false;
	Token *table = GetNextWordToken("TABLE", L"TABLE", 5);
	if(table == NULL)
		return false;
    STATS_DECL
	PL_STMS_STATS_V("DECLARE LOCAL TEMPORARY TABLE", declare);
	Token *name = GetNextIdentToken();
	if(name == NULL)
		return false;
	if(Target(SQL_SQL_SERVER, SQL_SYBASE) == true)
		ConvertToTsqlVariable(name);
	_spl_declared_local_tables.Add(name);
	 (void) GetNextCharToken('(', L'(');
	ListW pkcols;
	ParseCreateTableColumns(declare, name, pkcols, NULL, NULL, NULL, NULL, NULL, NULL);
	 (void) GetNextCharToken(')', L')');
	ParseTempTableOptions(name, NULL, NULL, NULL);
	if(_target == SQL_SQL_SERVER)
	{
		Token::Remove(local, temporary);
		AppendNoFormat(name, " ", L" ", 1);
		AppendCopy(name, table);
		Token::Remove(table);
	}
	return true;
}
bool SqlParser :: ParseDeclareLocalTemporaryTable ( Token * declare , Token * local ) { if ( declare == NULL || local == NULL ) return false ; if ( local -> Compare ( " " , L" " , 5 ) == false ) return false ; Token * temporary = GetNextWordToken ( " " , L" " , 9 ) ; if ( temporary == NULL ) return false ; Token * table = GetNextWordToken ( " " , L" " , 5 ) ; if ( table == NULL ) return false ; STATS_DECL PL_STMS_STATS_V ( " " , declare ) ; Token * name = GetNextIdentToken ( ) ; if ( name == NULL ) return false ; if ( Target ( SQL_SQL_SERVER , SQL_SYBASE ) == true ) ConvertToTsqlVariable ( name ) ; _spl_declared_local_tables . Add ( name ) ; ( void ) GetNextCharToken ( ' ' , L' ' ) ; ListW pkcols ; ParseCreateTableColumns ( declare , name , pkcols , NULL , NULL , NULL , NULL , NULL , NULL ) ; ( void ) GetNextCharToken ( ' ' , L' ' ) ; ParseTempTableOptions ( name , NULL , NULL , NULL ) ; if ( _target == SQL_SQL_SERVER ) { Token :: Remove ( local , temporary ) ; AppendNoFormat ( name , " " , L" " , 1 ) ; AppendCopy ( name , table ) ; Token :: Remove ( table ) ; } return true ; }
DECLARE LOCAL TEMPORARY TABLE in Sybase ASA
DECLARE LOCAL TEMPORARY TABLE in Sybase ASA
// Table name // Add @ for parameter names for SQL Server and Sybase // Next token must be ( /*Token *open */ // Next token must be ) /*Token *close */ // Optional ON COMMIT DELETE | PRESERVE ROWS // DECLARE @name TABLE (columns) in SQL Server