Page 1 of 1
Another datbaseerror() request
Posted: Tue Jan 22, 2013 6:02 am
by jassing
Is there a way to reset / clear the databaseerror()/
Since it doesn't tell you what db or what query went wrong, if you use multiple databases at once, and if you have an error in one database, "the other" might catch databaseerror()
Re: Another datbaseerror() request
Posted: Tue Jan 22, 2013 12:32 pm
by Fred
How can it happen, do you have an example ? DatabaseError() should only be called when an error occured, you should not rely on it if no error occured.
Re: Another datbaseerror() request
Posted: Tue Jan 22, 2013 5:38 pm
by jassing
Let's say
THREAD #1
if databasequery(0,"Select * order by id;")
else
debug databaseerror()
endif
Thread #2
if datbasequery(1,"Select * from non-existent table;")
else
debug databaseerror()
endif
If you have these two threads - let's say thread #1 query runs 1st, but right after it thread 2's query is run.
databaseerror() is for the "most recently run error" not the last error on that database.
(If the queries worked off query-handles rather than database handles, the error would be more specific, and then you could run two queries w/o opening a file twice...)
but based on the response, I'm the only one that has seen this sort of thing, so...
Re: Another datbaseerror() request
Posted: Tue Jan 22, 2013 7:51 pm
by Fred
No, DatabaseError() works by thread, so each thread has its own error string stored. That's why I don't know where the problem is, as what you describe can't happen.
Re: Another datbaseerror() request
Posted: Tue Jan 22, 2013 9:41 pm
by jassing
Fred wrote:No, DatabaseError() works by thread, so each thread has its own error string stored. That's why I don't know where the problem is, as what you describe can't happen.
OK -- because I got an error that doesn't make sense for where it was caught; but could make sense for an entirely different query... weird.
Re: Another datbaseerror() request
Posted: Tue Jan 22, 2013 10:32 pm
by freak
Did you enable the threadsafe switch in the compiler options?
Re: Another datbaseerror() request
Posted: Wed Jan 23, 2013 4:16 am
by jassing
freak wrote:Did you enable the threadsafe switch in the compiler options?
yes.