View previous topic :: View next topic |
Author |
Message |
DM Agonia
Joined: 07 Nov 2008 Posts: 4
|
Posted: Fri Nov 07, 2008 23:38 Post subject: Syntax Error |
|
|
Hi all..
Here's my problem.
I'm using NWNX with SQLITE. I've installed NWNX and ODBC.
Now..
I'm trying to delete a single row from a silly table...but...here's the mistake.
! SQL Error: near "LIMIT": syntax error
Here's my call..
sSQL = "DELETE * FROM vendor_png WHERE png_tag='"+ sPngTag +"' AND obj_resref='"+ sResRef +"' AND obj_stacksize='"+ sStackSize +"' AND pg_name='"+ sName +"' AND pg_account='"+ sAccount +"' LIMIT 1";
What do you think about?
Thank you. |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Fri Nov 07, 2008 23:44 Post subject: |
|
|
In SQLite, you can specify LIMIT for SELECT queries only.
Last edited by virusman on Fri Nov 07, 2008 23:46; edited 1 time in total |
|
Back to top |
|
|
DM Agonia
Joined: 07 Nov 2008 Posts: 4
|
Posted: Fri Nov 07, 2008 23:45 Post subject: |
|
|
I had the same error with DAY() and MOUNTH() functions..
But..how can i delete a single row then? |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
|
Back to top |
|
|
DM Agonia
Joined: 07 Nov 2008 Posts: 4
|
Posted: Fri Nov 07, 2008 23:50 Post subject: |
|
|
so i have to wite limit 1 offset 0?
In that link there's the delete-smt-limited |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Fri Nov 07, 2008 23:52 Post subject: |
|
|
DM Agonia wrote: | In that link there's the delete-smt-limited | The library has to be compiled with that option for this to work. |
|
Back to top |
|
|
DM Agonia
Joined: 07 Nov 2008 Posts: 4
|
Posted: Fri Nov 07, 2008 23:54 Post subject: |
|
|
I'm not so nerd...and i'm under windows..
How can i use limit in sqlite or something like that? I've to delete only one row of due-tree-four identical.. |
|
Back to top |
|
|
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Sun Nov 09, 2008 14:24 Post subject: |
|
|
Where's your primary key? This is exactly the reason that primary keys are so important. EVERY table must have a primary key. It can be composite, but without a primary key, you get into all sorts of problems like this.
In SQLite there is no ALTER TABLE function, so you should use CREATE TEMPORARY TABLE to clone the existing table, copy all the data across, then delete the old table, CREATE TABLE a new one with an auto-incrementing ID field or something and finally copy the data across.
Not neat, but better than not having a primary key. |
|
Back to top |
|
|
Xildjian
Joined: 08 Jan 2005 Posts: 100
|
Posted: Sun Nov 09, 2008 17:46 Post subject: |
|
|
Don't you want just a DELETE instead of DELETE * ?
I had an issue like that the other day, where the DELETE * was not correct syntax. _________________ Member Shadow of Iniquity development team |
|
Back to top |
|
|
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Mon Nov 10, 2008 18:44 Post subject: |
|
|
Xildjian wrote: | Don't you want just a DELETE instead of DELETE * ?
I had an issue like that the other day, where the DELETE * was not correct syntax. |
DELETE * is certainly not valid SQL, well spotted. Some SQL engines do however support this variation. But yes, DELETE is the correct form. |
|
Back to top |
|
|
|