[Gambas-user] too many operands

Doriano Blengino doriano.blengino at ...1909...
Mon Sep 7 13:11:56 CEST 2009


MSulchan Darmawan ha scritto:
> Dear all,
>
> Any suggestion to simplify this code ? I had "Expression too complex,
> too many operands" warning :D
> I have 36 fields data to insert.
>
>     sSql = "INSERT INTO refpos (id, idpos, year, month, day, " & 
>                   "r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, " &
>                   "r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, " &
>                   "r21, r22, r23, r24, r25, r26, r27, r28, r29, r30, r31" &
>                    ") VALUES " &
>            "('" & hRes!iddata & "', '" & hRes!idpos & "', '" & hRes!yr & "', '" & hRes!mn & "', '" & hRes!dt & "', '" &
>            hRes!r1 & "', '" & hRes!r2 & "', '" & hRes!r3 & "', '" & hRes!r4 & "', '" & hRes!r5 & "', '" & hRes!r6 & "', '" & hRes!r7 & "', '" & hRes!r8 & "', '" & hRes!r9 & "', '" & hRes!r10 & "', '" & 
>            hRes!r11 & "', '" & hRes!r12 & "', '" & hRes!r13 & "', '" & hRes!r14 & "', '" & hRes!r15 & "', '" & hRes!r16 & "', '" & hRes!r17 & "', '" & hRes!r18 & "', '" & hRes!r19 & "', '" & hRes!r20 & "', '" & 
>            hRes!r21 & "', '" & hRes!r22 & "', '" & hRes!r23 & "', '" & hRes!r24 & "', '" & hRes!r25 & "', '" & hRes!r26 & "', '" & hRes!r27 & "', '" & hRes!r28 & "', '" & hRes!r29 & "', '" & hRes!r30 & "', '" & hRes!r31 &
>             "')"
>   
I think the most correct way to do this is something like this (don't 
mind the field names - they are from my program):

    res = db.Create("refpos")      ' append record in table named refpos
    res!datain = edData.Text       ' set field by field
    res!tcaus = 2
    res!cer = st

    IF ckEsente.Value = TRUE THEN  ' you can do calculations in between
      res!statofisico = 1
    ELSE
      res!statofisico = 0
    ENDIF
    res!clifor = edConf.Text
    res!qtaton = utils.formatted2float(tvRighi[i, 3].text) ' qta
    res.Update
    ' ^^^^^ don't forget to update...

Regards,
Doriano







More information about the User mailing list