[Gambas-user] use of ORDER BY in gb.Find

Benoît Minisini gambas at ...1...
Mon Feb 8 15:36:36 CET 2010


> The follwing code works
> 
> hResult = $hConn.Find("addresses", , "ORDER BY lastname")
> 
> but result is not sorted.  Of course I could use .EXEC with full SQL string
> but....
> 

The request is only in the second argument of Find() (see documentation). The 
other arguments are substituted inside the request, a bit like the Subst() 
function.

You must put your "ORDER BY" inside the second argument.

But as Find() internally adds "WHERE" to the query beginning by default, you 
must write it like that:

hResult = $hConn.Find("addresses", "WHERE True ORDER BY lastname")

Maybe Find() should be more clever, and detect ORDER BY too. I will implement 
that for Gambas 3.

Regards,

-- 
Benoît Minisini




More information about the User mailing list