Another datbaseerror() request

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Another datbaseerror() request

Post 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()
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Another datbaseerror() request

Post 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.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Another datbaseerror() request

Post 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...
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Another datbaseerror() request

Post 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.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Another datbaseerror() request

Post 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.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Another datbaseerror() request

Post by freak »

Did you enable the threadsafe switch in the compiler options?
quidquid Latine dictum sit altum videtur
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Another datbaseerror() request

Post by jassing »

freak wrote:Did you enable the threadsafe switch in the compiler options?
yes.
Post Reply