Is DatabaseQuery result always on the 1st row?

Just starting out? Need help? Post your questions and find answers here.
swhite
Enthusiast
Enthusiast
Posts: 727
Joined: Thu May 21, 2009 6:56 pm

Is DatabaseQuery result always on the 1st row?

Post by swhite »

After you have executed a DatabaseQuery() is the position in the result set always on the first row or is it necessary to always use
NextDatabaseRow(). For example if I know the result set only has one row can I immediately use functions like GetDatabaseString() etc without using NextDatabaseRow()?

I know I can test this but what I am looking for is understanding of exactly what Purebasic does so I can always count on the behavior as opposed to having stumbled on an undocumented feature that could change in future versions.

Thanks
Simon
Simon White
dCipher Computing
infratec
Always Here
Always Here
Posts: 6871
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Is DatabaseQuery result always on the 1st row?

Post by infratec »

You need

Code: Select all

If NextDatabaseRow()
Bernd
User avatar
Bisonte
Addict
Addict
Posts: 1232
Joined: Tue Oct 09, 2007 2:15 am

Re: Is DatabaseQuery result always on the 1st row?

Post by Bisonte »

infratec wrote:You need

Code: Select all

If NextDatabaseRow()
Bernd
Yes. After a DataBaseQuery() the pointer of the result row is not defined. so the NextDatabaseRow() command is needed to put it on the "next" element (or to the first row).

Its nearly the same behaviour like lists in PB.
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: Is DatabaseQuery result always on the 1st row?

Post by citystate »

if you only have a single row in a query, there's also

Code: Select all

FirstDatabaseRow(#Database)
as an option
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
User avatar
mk-soft
Always Here
Always Here
Posts: 5398
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Is DatabaseQuery result always on the 1st row?

Post by mk-soft »

citystate wrote:if you only have a single row in a query, there's also

Code: Select all

FirstDatabaseRow(#Database)
as an option
Not all database drivers support them. '#PB_Database_DynamicCursor'
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply