Developer forum

Forum » Integration » Possible to only delete a subset of rows?

Possible to only delete a subset of rows?

Morten Bengtson
Reply
Hi,

Does anybody know if it is possible to only delete a subset of rows after an import?

In my case I want to import users to a specific group and then remove all "old users" from the AccessUser table, but only users in that specific group.

Only alternative I see is to set the AccessUserValidTo date on each import and then old users will automatically become inactive when they are not imported anymore. I think that would work, but then we end up having a lot of  garbage (inactive users) in user management :/

Replies

 
Dmitriy Benyuk
Reply
This post has been marked as an answer
Hi Morten,

it is possible to write the sql command inside the Close method of your Provider. It will be called after import. Also there should be some _connection to the db if you are reading/writting to it.
For example:
 
public new void Close()
{
		SqlCommand command = new SqlCommand { Connection = _connection };
                if (_connection.State.ToString() != "Open")
                    _connection.Open();

                string sql = "UPDATE EcomOrders SET OrderIsExported = 1";
                _command.CommandText = sql;

                command.ExecuteNonQuery();
		_connection.Close();
}
 

Votes for this answer: 0
 
Morten Bengtson
Reply
Hi Dmitriy,

Thanks for your reply. I have created a feature request :)
http://developer.dynamicweb-cms.com/forum.aspx?ThreadID=29684

/Morten

 

You must be logged in to post in the forum