View previous topic :: View next topic |
Author |
Message |
xorbaxian
Joined: 18 Dec 2007 Posts: 45
|
Posted: Tue Dec 18, 2007 18:09 Post subject: error checking for void functions? |
|
|
hi,
i'm new to nwnx2 and can't find the answer to this one in the docs. how can i check the success of an sqlexec call like INSERT, UPDATE, CREATE, etc? i'm looking for something analogous to the the SQL_SUCCESS and SQL_ERROR for sqlfetch(). is this stored in a global variable someplace?
thanks |
|
Back to top |
|
|
Squatting Monk
Joined: 28 Jun 2007 Posts: 76
|
Posted: Thu Dec 20, 2007 2:38 Post subject: |
|
|
There is nothing analogous to SQLFetch for INSERT, UPDATE, or CREATE. You could make functions to work around this, though they'll be kludges. If you're not needing to find out whether the functions succeeded from within the script, you can always look at the log. Any errors have ! at the beginning of their entry, so just do a search for ! if there's a lot of entries to search through. |
|
Back to top |
|
|
xorbaxian
Joined: 18 Dec 2007 Posts: 45
|
Posted: Thu Dec 20, 2007 18:49 Post subject: |
|
|
thanks for the reply. actually, i am looking for a way to test for success of the operation within the script. i want to be able to report to the user that the store operation was successful -- or not.
it seems strange to me that there'd be no way at all to check this; there are any number of things that could go wrong during a write.
any ideas?
thanks again for your input! |
|
Back to top |
|
|
cadderly
Joined: 05 Dec 2007 Posts: 8
|
Posted: Fri Dec 21, 2007 13:35 Post subject: |
|
|
You can use mysql internal variables or functions to check for the number of rows that a SELECT would return. Or how many rows where inserted
Or check the mysql error
http://dev.mysql.com/doc/
Search for internal functions FOUND_ROWS(), ROW_COUNT() |
|
Back to top |
|
|
xorbaxian
Joined: 18 Dec 2007 Posts: 45
|
Posted: Fri Dec 21, 2007 16:50 Post subject: |
|
|
cadderly wrote: | You can use mysql internal variables or functions to check for the number of rows that a SELECT would return. Or how many rows where inserted
Or check the mysql error
| hmmm.... this doesn't seem to be the case. in fact, it doesn't seem like it would be the case either, because nwnx adds a layer of abstraction over the database type [mysql, sqllite, odbc, ...] so calling a db-specific function like mysql_error() won't be available. in any event, there doesn't seem to be any way of accessing these functions from within the toolset and they aren't defined in aps_include, so i get a compile error.
it looks like all storage operations ultimately call SQLExecDirect(), which just writes a string into a module variable and returns. does the nwnx server simply monitor this variable and copy it out whenever it changes, then write the result of the operation back into another module variable when the sql operation is finished?
to sum up, using the sqlerror() or sqlerrno() function is exactly what i'm looking for, but it doesn't seem to exist in nwnx. is there a way to get this information?
thanks. |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Fri Dec 21, 2007 18:13 Post subject: |
|
|
Windows or Linux? |
|
Back to top |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Sat Dec 22, 2007 0:09 Post subject: |
|
|
It's available in the SQLServer plugin (which is based on ODBC), but that doesn't help you. It's available if anyone wants to retrofit it back in the MySQL plugin.
Cheers
Gryphyn |
|
Back to top |
|
|
xorbaxian
Joined: 18 Dec 2007 Posts: 45
|
Posted: Sat Dec 22, 2007 0:25 Post subject: |
|
|
virusman wrote: | Windows or Linux? |
windoze.
Gryphyn wrote: | It's available in the SQLServer plugin (which is based on ODBC), but that doesn't help you. It's available if anyone wants to retrofit it back in the MySQL plugin. |
would this involve recompiling the odbc/nwnx source, or is there a hook buried someplace i might be able to get at with nwscript? |
|
Back to top |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Sat Dec 22, 2007 0:52 Post subject: |
|
|
It needs to be added to the MySQL plugin (involving a re-compile).
G |
|
Back to top |
|
|
|