private void RemoveReference(String statementName, String variableName)
        {
            // remove from variables
            var statements = _variableToStmt.Get(variableName);

            if (statements != null)
            {
                if (!statements.Remove(statementName))
                {
                    Log.Info("Failed to find statement name '" + statementName + "' in collection");
                }

                if (statements.IsEmpty())
                {
                    _variableToStmt.Remove(variableName);

                    if (!_configuredVariables.Contains(variableName))
                    {
                        _variableService.RemoveVariableIfFound(variableName);
                        _tableService.RemoveTableIfFound(variableName);
                        _namedWindowMgmtService.RemoveNamedWindowIfFound(variableName);
                    }
                }
            }

            // remove from statements
            var variables = _stmtToVariable.Get(statementName);

            if (variables != null)
            {
                if (!variables.Remove(variableName))
                {
                    Log.Info("Failed to find variable '" + variableName + "' in collection");
                }

                if (variables.IsEmpty())
                {
                    _stmtToVariable.Remove(statementName);
                }
            }
        }
        public bool RemoveVariable(String name, bool force)
        {
            if (!force)
            {
                ICollection <String> statements = _statementVariableRef.GetStatementNamesForVar(name);
                if ((statements != null) && (statements.IsNotEmpty()))
                {
                    throw new ConfigurationException("Variable '" + name + "' is in use by one or more statements");
                }
            }

            var reader = _variableService.GetReader(name, EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID);

            if (reader == null)
            {
                return(false);
            }

            _variableService.RemoveVariableIfFound(name);
            _statementVariableRef.RemoveReferencesVariable(name);
            _statementVariableRef.RemoveConfiguredVariable(name);
            return(true);
        }