More than 1 Database Query open at a time
More than 1 Database Query open at a time
Hi
It would be useful to have more than one database query open at a time.
Thanks,
Simon
It would be useful to have more than one database query open at a time.
Thanks,
Simon
Simon White
dCipher Computing
dCipher Computing
Re: More than 1 Database Query open at a time
Hi Simon. Is it not possible to do so now?swhite wrote: Sat Oct 12, 2024 5:56 pmIt would be useful to have more than one database query open at a time.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: More than 1 Database Query open at a time
DatabaseError() and some other commands don't have parameters so it's impossible to know which call caused an error.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: More than 1 Database Query open at a time
The DatabaseError() function simply retrieves the last database error. This is usually implemented in error handling and would be directly associated with a database operation. So, it's not totally impossible to determine the affected database.jacdelad wrote: Sun Oct 13, 2024 7:14 amDatabaseError() and some other commands don't have parameters so it's impossible to know which call caused an error.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: More than 1 Database Query open at a time
...that's what I meant.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: More than 1 Database Query open at a time
I thought you meant that it is impossible.
jacdelad wrote: Sun Oct 13, 2024 7:14 am DatabaseError() and some other commands don't have parameters so it's impossible to know which call caused an error.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: More than 1 Database Query open at a time
It is impossible, because you can't know which call caused the error (given you do multiple calls at once, threaded). Sure, it is technically possible but you will run into problems.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: More than 1 Database Query open at a time
It would be very unwise to access common database connections from separate threads. Each thread should have its own database connection, and as such, they should work independently of the others. With such models, the DatabaseError() issue would also work independently.jacdelad wrote: Sun Oct 13, 2024 8:42 amIt is impossible, because you can't know which call caused the error (given you do multiple calls at once, threaded). Sure, it is technically possible but you will run into problems.
Furthermore, asynchronous database connections should consider many other factors, like transaction isolation and concurrency control. Best to keep database management basic.

Nevertheless, I believe that this feature request is for nested queries, and not for concurrent connections.

Last edited by TI-994A on Sun Oct 13, 2024 12:58 pm, edited 1 time in total.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: More than 1 Database Query open at a time
Normally this is not needed.
You can solve it in a 'better' SQL command.
If you can not ..., open a second connection to the database.
You can solve it in a 'better' SQL command.
If you can not ..., open a second connection to the database.
Re: More than 1 Database Query open at a time
I tried with threads, but it didn't work reliable. Even with only one query in a thread, to not block the main loop, it wasn't satisfying.
Never thought about nested queries, because, like infrared wrote, it usually shouldn't be needed.
Never thought about nested queries, because, like infrared wrote, it usually shouldn't be needed.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: More than 1 Database Query open at a time
It appears to me that only one query per connection is possible. I am use to opening a connection to a database but then being able to open several queries. So I assumed I could do the same in PB but that is not the case. There are times when looping through several queries is needed to update other tables. An SQL statement to do this can be quite complex and hard to test all the edge cases. It is often easier to open several queries instead. Having said that perhaps I have not understood PB database design. In such a scenario should I being opening multiple connections to the database so that each connection can have its own query? Usually I try to minimize the connections to a database so I never thought of doing it this way before.
Simon
Simon
Simon White
dCipher Computing
dCipher Computing
- NicTheQuick
- Addict
- Posts: 1519
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: More than 1 Database Query open at a time
Opening several database cursors and doing queries to data that will be used in another query is never a good idea. If other users use the same database at the same time this can lead to inconsistency.
When you are working with multiple data and you need a complex query or even multiple ones, always start a transaction on your single database cursor and do all your stuff within that transaction, in the end do a commit. Only this way the database is able to be consistent afterwards.
When you are working with multiple data and you need a complex query or even multiple ones, always start a transaction on your single database cursor and do all your stuff within that transaction, in the end do a commit. Only this way the database is able to be consistent afterwards.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.