delete

How to optimize delete with date range where clause?

I created an android app and there is a function that will periodically delete old records delete from tablea where col1 = 'value1' and col2 = 'value2' and postdate < '2010-06-14' It has performance problem when total number of row in tablea has more then 50,000. It take around 45 seconds to delete 500 records. I already have index f...

EF4 how to delete entity in many-to-many relationship using POCOs

Hi, I'm using POCOs in combination with EF4 and some entities are in many-to-many relationships, in my case objects of class User and objects of class PrivilegeGroup. This is how class User looks like: public class User { public int UserID { set; get; } public string UserName { get; set; } public string UserPassword { get...

Calling delete on two pointers to the same object.

I'm having a problem with a couple of event handler classes I'm trying to write. Basically, the idea is to have an event handler class for each logical group of objects. In most cases, the events are between objects and their handler, but in some cases events are also sent between handler objects as well. I've written the code such that...

Pros & Cons of TRUNCATE vs DELETE FROM

Hey everyone, Could someone give me a quick overview of the pros and cons of using the following two statements: TRUNCATE TABLE dbo.MyTable vs DELETE FROM dbo.MyTable It seems like they both do the same thing when all is said and done; but are there must be differences between the two. Thanks again! ...

How can I override the DevExpress GridView delete

I've got a table (myTable) that I want to remove rows from but not delete them. I'm expiring them by using an myTable.ActiveFlag. So when I "delete" a row from myTable, I'd like to run UPDATE myTable SET ActiveFlag = 0 WHERE id = @rowId What is the best way to do this using a DevExpress Gridcontrol with GridView? I've currently: Priva...

iBatis Java: Dynamic table names in DELETE

iBatis 3 has a wonderful ability in SELECT statements to provide dynamic substitution before statement is prepared. For example this will work <select id="foo">SELECT * FROM $db$.MY_TABLE</select> However I can't make it work when trying to empty table XML code: <delete id="del" parameterType="String">DELETE FROM $db$.MY_TABLE</dele...

errorCode for The process cannot access the file 'XYZ' because it is being used by another process

I using C# .NET , vs 2008 , .net 3.5 For me, is difficult, but I need sample code in C# for this: How get the error code of IOException "The process cannot access the file 'XYZ' because it is being used by another process." For example, in my issue. I try delete file, and I get "The process cannot access the file 'XYZ' because it...

Delete records within Instead Of Delete trigger

I want to have an instead of delete trigger so that I can get text field values out of the table row that's being deleted to preserve those fields when the actual delete occurs. For some reason I can't pull them from the Deleted table in a standard Delete trigger (SQL errors out). Is there a way to do an actual delete within in an "inst...

Appearance of table cells when deleting

I'm trying to make a table view with an appearance much like the default Weather application provided by Apple. However I'm struggling a bit to make the table cells look correctly. I would like all the cells, except the first one to be deletable. The problem is that the default cells have the small delete button on the left side of the ...

MySQL - Check if a string contains numbers

Hello, how do I check if a string in a MySQL field contains a number then delete them? Example table: tbl_tags ------------- | id | tag | ------------- | 1 | hello | | 2 | hello2 | | 3 | 2hello | | 4 | hel3lo | ------------- The only way I can think of is to do each number individually and use LIKE '%1%' OR LIKE '%2%' etc....

SQL Server 2005: Deleting multiple rows with a single query

This should be a straightforward question, but I haven't found a clear answer yet. Does anyone know how to delete multiple rows from a single table in SQL Server 2005, using a single query? I wondered if it might just be the opposite of inserting multiple rows, using the UNION ALL method. So would this work? : DELETE FROM Table (Name, L...

Null Pointer Exception when using delete

AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); dDbHelper.deletedJournal(info.id); mDbHelper.deleteJournal(info.id); public boolean deletedJournal(long homeId){ return mDb.delete(DATABASE_TABLE, KEY_HOMEID + "=" + homeId, null )>0; } dDbHelper.deletedJournal(in...

[C++] Why doesn't delete destroy anything ?

I'm playing a little with memory dynamic allocation, but I don't get a point. When allocating some memory with the new statement, I'm supposed to be able to destroy the memory the pointer points to using delete. But when I try, this delete command doesn't seem to work since the space the pointer is pointing at doesn't seem to have been ...

WiX installer remove files on uninstall but not on upgrade.

I have a program that installs with a WiX installer. The program itself creates a number of files in the [CommonAppDataFolder]\[MyAppName]\ directory. These files all have the same extension (lets call it .dat). On upgrading, I want to retain these files. On uninstalling, I want to remove these files. I am currently deleting the fil...

Deleting files created with FileOutputStream

Hi, I'm developing for the Android platform. My app creates a temp file with a simple call to: FileOutputStream fos = openFileOutput("MY_TEMP.TXT",Mode); It works fine because I can write to it and read it normally. The problem is that when I exit from the app I want to delete this file. I used: File f = new File(System.getProperty(...

How to delete all associations in a Hibernate JoinTable at once?

We have the following two entities with many-to-many association: @Entity public class Role { ... @ManyToMany @JoinTable( name = "user_has_role", joinColumns = { @JoinColumn( name = "role_fk" ) }, inverseJoinColumns = { @JoinColumn( name = "user_fk" ) } ) private Set<User> userCollection; ... } and @Entity publi...

Is this a good solution to remove duplicate MySQL rows?

I saw the solution to create an alternate temporary MySQL table with unique rows, but I didn't like that idea, as my tables are very large and would be a hassle to move them (and would create huge problems if there would be errors during the move). I did, however, find the following. What do you think of this (where the duplicates to ch...

Double free coruption

Hi, I have a class call grid. The class holds two 2d char arrays for storing a grid... The class has two functions for creating the memory for the grid and releasing the memory for the grid. Grid.h private: char **gridOne; char **gridTwo; Grid.cpp void Grid::allocateGridMem() { _gridOne = new char*[gridRowCount()]; _gridTwo =...

mysql delete all rows and keep latest x left

Hi, i have a table like entryid, roomid 1 1 2 55 3 1 4 12 5 1 6 44 7 1 8 3 9 1 now I would like to delete ALL entries where roomid = 1 and keep the latest 3 from roomid = 1 left (best with just one command) so finaly entryid: 1 & 3 ...

how to delete row values in a datagridview in windows forms c#?

Hi friends my table name is nametable wherein i can store names like john bob I am projecting the table values in the datagridview, and i am using delete button, for that i have written code below. But it deletes the data in the table and not showing in datagridview. How to solve it? private void dataGridView1_CellContentClick(object ...