[Gambas-user] Extracting fields from a Result

Doug Hutcheson owlbrudder at gmail.com
Mon Jan 1 07:19:34 CET 2018



On Sun, 2017-12-31 at 16:23 -0500, T Lee Davidson wrote:
> On 12/31/2017 03:16 PM, Tobias Boege wrote:
> > On Sun, 31 Dec 2017, T Lee Davidson wrote:
> > > Yes, MyResult!txtMasterDatabase should work. (Did you copy/paste
> > > that name, or type it in directly?) The For Each loop should
> > > work as well.
> > > 
> > > I tried a simple command-line application on a MySQL data table
> > > with just one row. All the application does is, first connect to
> > > the database, and then 'MyResult = hConn.Exec("select * from
> > > users")'
> > > 
> > > A For Each loop prints the field names just fine. And, 'Print
> > > MyResult!id' displays the correct value.
> > > 
> > > Perhaps there is a bug in the Gambas PostgreSQL driver. Can you
> > > test on a MySQL table to see if that works for you?
> > > 
> > 
> > I agree that the original code should have worked. See the attached
> > script which uses an in-memory SQLite3 database to demonstrate that
> > it works with another driver.
> > 
> > A (minimal!) project and database dump, just enough to reproduce
> > the
> > behaviour, would be helpful.
> > 
> > Regards,
> > Tobi
> 
> I installed a PostgreSQL server. PostgreSQL does not appear at first
> glance to be as easy to work with as MySQL.
> 
> After finally figuring out how to configure and use it, I was able to
> run a simple command-line application to successfully
> print the field names. (Interestingly enough, even without the
> gb.db.postgresql database driver component enabled! Benoît?)
> 
> It does work as you expect it should, Doug.
> 
> You will find my code and the output below.
> 
> 
Thanks Lee and Tobi (and others) for sticking with me on this.

I can now report s follows:

For a PostgreSQL object on my machine:
An indexed For ... Next loop works fine
A For Each ... Next always fails at the first line - see attached
image. Gambas is reporting it can't find a field of a given name, but
it has to have found it in order to report its name.

For a MySQL (MariaDB) connection on my machine, both forms of loop work
fine.

Using the Connection option from the project window, I can see and
browse all data in both types of database.

So, it appears to be a glitch in the way the code is executed in a For
Each loop on a PostgreSQL object. Having said that. I have previously
had issues with executables from the Fedora repositories misbehaving,
so I installed Gambas from the Gambas repositories instead and proved
the issue was still there.

Lee has reported different behaviour, so something is definitely screwy
on my system. Sigh.

How do I prepare my project and transmit it to the list?

Kind regards,
Doug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180101/69639c7a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Gambas screenshot showing error message from For Each loop.png
Type: image/png
Size: 16542 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180101/69639c7a/attachment-0001.png>


More information about the User mailing list