SQLite: Trouble deleting row.
#1

I'm trying to delete a row with.
pawn Код:
DELETE FROM Doors WHERE ID = 2
But it doesn't work at all.
Reply
#2

Tried wrapping the tablename in quotes?

pawn Код:
DELETE FROM `Doors` WHERE ID = 2
SQL can be quite sensitive with syntax, other than that seems like it would work fine assuming that you have a table called "Doors" with a column called ID where there is a row with a value of 2 in the ID field.

Is this being done through PAWN? If so, can we see the PAWN code?
Reply
#3

I wrapped the tablename with those quotes, I do have a table named Doors, there is a collumn called ID, and there is a row where ID is equal to 2. Still no result.

This is also being done through a command.
pawn Код:
CMD:destroydoor(playerid, params[])
{
    // ...
    new id = strval(params);
    DestroyDoor(id);
    return 1;
}
public DestroyDoor(id)
{
    new
        string[128]
    ;
    format(string, sizeof(string), "DELETE FROM `Doors` WHERE ID = %d", id);
    // ...
    db_query(Database, string);
    return 1;
}
Reply
#4

Not familiar with SQLite; does it have logs?

Try sending the query via phpMyAdmin and see what, if any, errors appear.

EDIT: I bet it's caused by ID not being enclosed in ``, try that.
Reply
#5

Did you try Doors without the quotes ?
Reply
#6

Quote:
Originally Posted by MP2
Посмотреть сообщение
Not familiar with SQLite; does it have logs?

Try sending the query via phpMyAdmin and see what, if any, errors appear.

EDIT: I bet it's caused by ID not being enclosed in ``, try that.
Yea, it's the sa-mp native SQLite, and it doesn't have any support like the MySQL Plugin does. (OnQueryError etc...)

I tried sending the query on my Database editor, but it won't work.

Also tried enclosing the collumn name with ` `, no result.
Reply
#7

Bump.
Reply
#8

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Yea, it's the sa-mp native SQLite, and it doesn't have any support like the MySQL Plugin does. (OnQueryError etc...)

I tried sending the query on my Database editor, but it won't work.

Also tried enclosing the collumn name with ` `, no result.
Do you get any errors? If so, what does the error say?

I can't see any issue really, it looks fine to me and assuming that all of the structures are correct like you've pointed out, I don't see why it wouldn't work. You could try providing us with the database file (unless it contains sensitive information) and it might make it easier to see what's going wrong.
Reply
#9

Your reply pushed me to keep on poking with shit.

Found out the issue. Apparently when you're deleting, you need to enclose the value you are looking for with apostrophes. I assumed only strings had to be enclosed with apostrophes.
Bad
pawn Код:
DELETE FROM `Table` WHERE `ID` = 9
Good
pawn Код:
DELETE FROM `Table` WHERE `ID` = '9'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)