sqlparser/sqlserver.cpp
// For SQL Server move cursor declarations that depend on procedural variables
For SQL Server move cursor declarations that depend on procedural variables
For SQL Server move cursor declarations that depend on procedural variables
void SqlParser::SqlServerMoveCursorDeclarations()
{
	ListwItem *cursor_item = _spl_declared_cursors_using_vars.GetFirst();
	while(cursor_item != NULL)
	{
		Token *cursor = (Token*)cursor_item->value;
		ListwmItem *open_item = _spl_open_cursors.GetFirst();
		Token *declare = NULL;
		Token *declare_end = NULL;
		while(open_item != NULL)
		{
			Token *open_stmt = (Token*)open_item->value;
			Token *open_cursor = (Token*)open_item->value2;
			if(Token::Compare(cursor, open_cursor))
			{
				ListwmItem *declare_item = Find(_spl_declared_cursors_stmts, cursor);
				if(declare_item != NULL)
				{
					declare = (Token*)declare_item->value2;
					declare_end = (Token*)declare_item->value3;
					PrependCopy(open_stmt, declare, declare_end, false);
					PREPEND(open_stmt, "\n");
				}
			}
			open_item = open_item->next;
		}
		if(declare != NULL && declare_end != NULL)
			Token::Remove(declare, declare_end);
		cursor_item = cursor_item->next;
	}
}
void SqlParser :: SqlServerMoveCursorDeclarations ( ) { ListwItem * cursor_item = _spl_declared_cursors_using_vars . GetFirst ( ) ; while ( cursor_item != NULL ) { Token * cursor = ( Token * ) cursor_item -> value ; ListwmItem * open_item = _spl_open_cursors . GetFirst ( ) ; Token * declare = NULL ; Token * declare_end = NULL ; while ( open_item != NULL ) { Token * open_stmt = ( Token * ) open_item -> value ; Token * open_cursor = ( Token * ) open_item -> value2 ; if ( Token :: Compare ( cursor , open_cursor ) ) { ListwmItem * declare_item = Find ( _spl_declared_cursors_stmts , cursor ) ; if ( declare_item != NULL ) { declare = ( Token * ) declare_item -> value2 ; declare_end = ( Token * ) declare_item -> value3 ; PrependCopy ( open_stmt , declare , declare_end , false ) ; PREPEND ( open_stmt , " \n " ) ; } } open_item = open_item -> next ; } if ( declare != NULL && declare_end != NULL ) Token :: Remove ( declare , declare_end ) ; cursor_item = cursor_item -> next ; } }
For SQL Server move cursor declarations that depend on procedural variables
For SQL Server move cursor declarations that depend on procedural variables
// Check of cursors that use variables // Find all OPEN statements for this cursor (the same cursor can be open multiple times) // Get cursor declaration statement // Now we can remove the original declaration