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 
 
New Query from within a while loop
Goto page Previous  1, 2
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sun Aug 16, 2009 6:17    Post subject: Reply with quote

Asparius wrote:
In multi-user environment maybe locking table for this query would prevent problems...

All prior stuff has multi-user issues...including what I've written Wink
when the select, delete & update are all separate SQLExec's there is the potential for things getting out-of-sync. phantom reads, missing entries etc.
Only by ensuring they are all in a single transaction, can you make sure of them (a stored procedure works)
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Aug 21, 2009 12:58    Post subject: Thx Reply with quote

Sorry for the delay.

Managed to solve it as per your advice by making a Stored Proc.

Now, all nwn script has to do is

Code:

string sSql = "CALL Renumber ()";
SQLDirectExecute(sSql); //or whatever the syntax is


Had some trouble writing the stored proc in phpmyadmin though.
Had to actually change the deliminator from ; symbol to @@ - apparently its a commonly known issue with Stored Proc's and phpmyadmin.

Thx for the help
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Fri Aug 21, 2009 13:21    Post subject: Reply with quote

stored procs are the way to go...
In particular the common 'insert on error update' sequence can be done with a single NWScript request.

*'update, if affected rows = 0 insert' will usually get you better performance as no error/exception is caused. (simple for a stored proc)
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
Goto page Previous  1, 2
Page 2 of 2

 
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