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 
 
error checking for void functions?

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



Joined: 18 Dec 2007
Posts: 45

PostPosted: Tue Dec 18, 2007 18:09    Post subject: error checking for void functions? Reply with quote

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



Joined: 28 Jun 2007
Posts: 76

PostPosted: Thu Dec 20, 2007 2:38    Post subject: Reply with quote

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



Joined: 18 Dec 2007
Posts: 45

PostPosted: Thu Dec 20, 2007 18:49    Post subject: Reply with quote

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



Joined: 05 Dec 2007
Posts: 8

PostPosted: Fri Dec 21, 2007 13:35    Post subject: Reply with quote

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



Joined: 18 Dec 2007
Posts: 45

PostPosted: Fri Dec 21, 2007 16:50    Post subject: Reply with quote

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



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Fri Dec 21, 2007 18:13    Post subject: Reply with quote

Windows or Linux?
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sat Dec 22, 2007 0:09    Post subject: Reply with quote

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



Joined: 18 Dec 2007
Posts: 45

PostPosted: Sat Dec 22, 2007 0:25    Post subject: Reply with quote

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



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sat Dec 22, 2007 0:52    Post subject: Reply with quote

It needs to be added to the MySQL plugin (involving a re-compile).

G
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