I have a table called Favourite tags. it has fields - Tag, User( Pointer- respectiv user objectid).where User can store a tag and along with user-objectid as pointer in user filed and user remove the tag from favourite
For Storing/Updating: it is working fine .
ParseObject favtagobject = new ParseObject("Favourite");
favtagobject.put("Tag", "#" + keyword);
favtagobject.put("User", ParseUser.getCurrentUser());
favtagobject.saveInBackground();
For removing/deleting the tag from table: Below code is not working
ParseObject favtagobject = new ParseObject("Favourite");
favtagobject.put("Tag", "#" + keyword);
favtagobject.put("User", ParseUser.getCurrentUser());
favtagobject.deleteInBackground(new DeleteCallback() {
@Override
public void done(com.parse.ParseException arg0) {
// TODO Auto-generated method stub
System.out.println("deleted the tag succesfully");
}
});
i want to delete a row from table i know which row to be deleted. Please help me out.
Introduction to SQL Server DELETE statement. To remove one or more rows from a table completely, you use the DELETE statement. The following illustrates its syntax: DELETE [ TOP ( expression ) [ PERCENT ] ] FROM table_name [ WHERE search_condition]; Code language: SQL (Structured Query Language) (sql) First, you specify the name of the table ...
The PostgreSQL DELETE statement allows you to delete one or more rows from a table. First, specify the name of the table from which you want to delete data after the DELETE FROM keywords. Second, use a condition in the WHERE clause to specify which rows from the table to delete. The WHERE clause is optional.
In this case, you need to specify the search_condition in the WHERE clause to limit the number of rows that are deleted. The rows that cause the search_condition evaluates to true will be deleted. The WHERE clause is optional. If you skip it, the DELETE statement will remove all rows from the table. Let’s create a new table for the demonstration.
Notice the WHERE clause in the DELETE statement. The WHERE clause specifies which record (s) should be deleted. If you omit the WHERE clause, all records in the table will be deleted! Below is a selection from the "Customers" table in the Northwind sample database:
Basically, when you use 'new ParseObject("Favourite");' it will construct a new ParseObject. This parseObject does not exist in your database until you call any variant of .save() on it. Hence when you do this
ParseObject favtagobject = new ParseObject("Favourite");
favtagobject.put("Tag", "#" + keyword);
favtagobject.put("User", ParseUser.getCurrentUser());
favtagobject.deleteInBackground(new DeleteCallback() {
@Override
public void done(com.parse.ParseException arg0) {
// TODO Auto-generated method stub
System.out.println("deleted the tag succesfully");
}
});
All you're doing is creating a new object, that does not exist in your database and then try to delete it? What you're looking for is this
ParseQuery<ParseObject> query = ParseQuery.getQuery("Favourite");
query.whereEqualTo("Tag", "#" + keyword);
query.whereEqualTo("User", ParseUser.getCurrentUser());
query.getFirstInBackground(new FindCallBack() {
@Override
public void done(ParseObject object, com.parse.ParseException arg0) {
// TODO Auto-generated method stub
object.delete();
object.saveInBackground();
}
}););
This will first get the object from your database and then delete the row from table and save the changes made to the object!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With