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 
 
Feedback on SQL "Update" statements

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Development
View previous topic :: View next topic  
Author Message
Morrandir



Joined: 13 Jan 2006
Posts: 27

PostPosted: Sun Dec 17, 2006 20:25    Post subject: Feedback on SQL "Update" statements Reply with quote

Hi there,

following problem: I need to perform an update statement, that does not in every case do a real update. (In case that the value has not changed in meantime.)
In these cases SQLGetAffectedRows() returns 0 as no row has been affected indeed. My problem is, that now I can not determine if the statmenet itself was succesfull or if the database is not reachable or my where condition is wrong, or something like that.
Is there a way to get appropriate feedback?
Or do I have to do a select statement before and have a look if the value really changed?

Thanks in advance.
_________________
German NWN1/2 Persistent World Hochwaldallianz
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Tue Dec 19, 2006 0:05    Post subject: Reply with quote

If your DB connection went down, there should be something in the log files, and that is not something that should be handled inside nwscript. Scripts should not care for proper DB setup. If you must, issue a SELECT 1 beforehand and read the result.

Whether your WHERE clause is wrong, you can not know without doing a SELECT first, IMHO.

If you need to know whether an UPDATE actually changes something, I would recommend doing a select first and maybe saving the extra call to the DB if no update is needed.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Morrandir



Joined: 13 Jan 2006
Posts: 27

PostPosted: Tue Dec 19, 2006 13:50    Post subject: Reply with quote

The 'problem' is, that my where clause is generated dynamically, so there could be errors in some cases. In this case I want a message to be sent to the PC, that caused the update statement.
It's not a big problem though, I just thought I overlooked a simple solution.

And all of you involved in this project, thanks for your work btw - I really appreciate it. Smile
_________________
German NWN1/2 Persistent World Hochwaldallianz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Development 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