Suggest using slBuildBindDat(sData$,"T") to return text in expected order.
CAST AS TEXT to the rescue if bind "B" or no bind parameter was used to insert any record like slbuildbinddat(sData$)
create table T1(C1)
slExeBind "Insert into T1 values(?)",slBuildBindDat("1") 'binary bind
slExeBind "Insert into T1 values(?)",slBuildBindDat("2") 'binary bind
slExeBind "Insert into T1 values(?)",slBuildBindDat("3","B") 'binary bind
slExeBind "Insert into T1 values(?)",slBuildBindDat("11") 'binary bind
Results:
11,2,3,1 Select c1 from t1 order by c1 binary order is not wanted
1,11,2,3 Select c1 from t1 order by (c1 CAST AS TEXT) CAST into correct text order
'-----------------------------------------------------------------------------------------------------------------------
THREADED tsResult AS STRING
#INCLUDE "sqlitening.inc"
FUNCTION PBMAIN () AS LONG 'BindWithCast.bas 9/18/18 CJ
slOpen ":memory:"
slexe "create table T1(C1)"
slExeBind "Insert into T1 values(?)",slBuildBindDat("1") 'binary since "T" was not used
slExeBind "Insert into T1 values(?)",slBuildBindDat("2","T") 'text
slExeBind "Insert into T1 values(?)",slBuildBindDat("3","T") 'text
slExeBind "Insert into T1 values(?)",slBuildBindDat("11","T") 'text
GetData "Select C1 from T1 order by C1"
GetData "Select C1 from T1 order by CAST(C1 AS TEXT)"
GetData "Select C1 from T1 order by CAST(C1 AS INTEGER)"
? tsResult,%MB_SYSTEMMODAL,"CAST - Mixed Binary and Text Data"
END FUNCTION
FUNCTION GetData (sql AS STRING) AS STRING
DIM sArray() AS STRING
slselary sql,sArray(),"Q9c"
tsResult+= sql + $CR + JOIN$(sArray(),",") + $CR + $CR
END FUNCTION