[Gambas-user] How to write sql query in gambas way

bb adamnt42 at gmail.com
Tue May 10 11:59:43 CEST 2022


On Tue, 2022-05-10 at 11:50 +0200, Gianluigi wrote:
> Il giorno mar 10 mag 2022 alle ore 11:24 bb <adamnt42 at gmail.com> ha
> scritto:
> 
> > On Tue, 2022-05-10 at 11:04 +0200, Gianluigi wrote:
> > > Il giorno mar 10 mag 2022 alle ore 05:18 Safiur Rahman
> > > <isafiur at gmail.com>
> > > ha scritto:
> > > 
> > > > Hi
> > > > 
> > > > That cannot be the answer. The array can be of variable count
> > > > and
> > > > count
> > > > may go to twenty or thirty.
> > > > 
> > > > 
> > > I thought it was implied, you can do something like this:
> > > 
> > > Public Sub Button2_Click()
> > > 
> > >   Dim aRes As New Result[11]
> > > 
> > >   For i As Integer = 0 To 10
> > >     aRes[i] = conn.Find("tbltest", "flddepartment = &1 ",
> > > xCountry[i])
> > >     If aRes[i].Available Then ListBox1.Add(aRes[i]!fldtitle)
> > >   Next
> > > 
> > > End
> > > 
> > > Regards
> > > Gianluigi
> > > 
> > > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> > Gianluigi,
> > That is still overcomplicating the problem. He is not constructing
> > the
> > WHERE part of the call properly.
> > To cut it short,
> > 
> > res = conn.Exec("select fldtitle from tbltest where flddepartment
> > in
> > &1", ["Austria", "Azerbaijan"])
> > 
> > is missing the "()" that are needed for the SQL "in" construct.
> > 
> > The answer is
> > 
> > res = conn.Exec("select fldtitle from tbltest where flddepartment
> > in
> > (&1)", ["Austria", "Azerbaijan"])
> > 
> > or possibly better in order to keep database independance truely
> > true,
> > 
> > res = conn.Exec("select fldtitle from tbltest where flddepartment
> > in
> > &1", "("&["Austria", "Azerbaijan"].Join(",")&")")
> > 
> > ...
> > 
> 
> Bruce,
> 
> it seems that your queries here are not supported (gb.db: DB_Format:
> unsupported datatype: -58432600)
> 
> Regards
> Gianluigi
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
Which one? The quicky using the "(&1)" in the SQL parameter or the
longer array expansion one. Because they both work here with sqlite3
and postgres. And as far as I know I am using the native gd.db classes?
b



More information about the User mailing list