[Gambas-user] Query for sorting not work

T Lee Davidson t.lee.davidson at gmail.com
Sun Sep 4 19:13:15 CEST 2022


On 9/4/22 12:15, Benoit Minisini wrote:
> I'm currently thinking, maybe I could add new substitution syntaxes to 
> tell Gambas if we want to substitute a value, a column name or a table name.
> 
> Something like that:
> 
> DB.Exec("SELECT * FROM [&1] WHERE column = &2 SORT BY '&3'", sTableName, sValue, sSortColumn)

That would make for cleaner looking SQL query building as opposed to using string concatenation with the ampersand. I agree with 
Gianluigi that what we already have is sufficient, but it would be a nice enhancement.

If you decide to add that enhancement, may I suggest the use of the back-tick (`) to mark column names since the single-quote is 
sometimes used for data values? Ie.:
DB.Exec("SELECT * FROM [&1] WHERE column = &2 SORT BY `&3`", sTableName, sValue, sSortColumn)


-- 
Lee


More information about the User mailing list