View previous topic :: View next topic |
Author |
Message |
Morrandir
Joined: 13 Jan 2006 Posts: 27
|
Posted: Sun Dec 17, 2006 20:25 Post subject: Feedback on SQL "Update" statements |
|
|
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 |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Tue Dec 19, 2006 0:05 Post subject: |
|
|
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 |
|
|
Morrandir
Joined: 13 Jan 2006 Posts: 27
|
Posted: Tue Dec 19, 2006 13:50 Post subject: |
|
|
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. _________________ German NWN1/2 Persistent World Hochwaldallianz |
|
Back to top |
|
|
|