logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Syntax Error

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
DM Agonia



Joined: 07 Nov 2008
Posts: 4

PostPosted: Fri Nov 07, 2008 23:38    Post subject: Syntax Error Reply with quote

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
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Fri Nov 07, 2008 23:44    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger
DM Agonia



Joined: 07 Nov 2008
Posts: 4

PostPosted: Fri Nov 07, 2008 23:45    Post subject: Reply with quote

I had the same error with DAY() and MOUNTH() functions..


But..how can i delete a single row then?
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Fri Nov 07, 2008 23:48    Post subject: Reply with quote

SQLite syntax is not identical to MySQL. Refer to the SQLite documentation:
http://www.sqlite.org/lang.html
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
DM Agonia



Joined: 07 Nov 2008
Posts: 4

PostPosted: Fri Nov 07, 2008 23:50    Post subject: Reply with quote

so i have to wite limit 1 offset 0?

In that link there's the delete-smt-limited
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Fri Nov 07, 2008 23:52    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger
DM Agonia



Joined: 07 Nov 2008
Posts: 4

PostPosted: Fri Nov 07, 2008 23:54    Post subject: Reply with quote

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
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Sun Nov 09, 2008 14:24    Post subject: Reply with quote

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
View user's profile Send private message
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Sun Nov 09, 2008 17:46    Post subject: Reply with quote

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
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Mon Nov 10, 2008 18:44    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group