1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
# testsuite_database_include section for BASIC256
# Modification History
# date programmer description
# 20140103 j.m.reneau split from main testsuite
currentsuite = "database"
dbopen "testsuite.db"
dbexecute "drop table if exists t;"
dbexecute "create table t (i integer primary key, d text);"
dbexecute "insert into t (i,d) values (1,'one');"
dbexecute "insert into t (i,d) values (2,'two');"
dbexecute "insert into t (i,d) values (3,NULL);"
dbopenset "select * from t order by d desc limit 1;"
call n("drow() - get row", dbrow(), true)
call n("dbint(0)=2", dbint(0), 2)
call s("dbstring(1)='two''", dbstring(1), "two")
call n("dbint('i')=2", dbint('i'), 2)
call s("dbstring('d')='two''", dbstring('d'), "two")
call n("drow() - get row", dbrow(), false)
# leave set open so that next stmt has to close
#
dbopenset "select * from t where i = 3;"
call n("drow() - get row", dbrow(), true)
call n("dbnull(0)=false", dbnull(0), false)
call n("dbnull(1)=true'", dbnull(1), true)
call n("dbnull('i')=false", dbnull('i'), false)
call n("dbnull('d')=true", dbnull('d'), true)
call s("dbstring(1)='''", dbstring(1), "")
call s("dbstring('d')='''", dbstring('d'), "")
call n("drow() - get row", dbrow(), false)
dbcloseset
#
t = freedb
print "freedb = " + t
dbopen t, "testsuite2.db"
dbexecute t, "drop table if exists t;"
dbexecute t, "create table t (i integer primary key, d text);"
dbexecute t, "insert into t (i,d) values (1,'one');"
dbexecute t, "insert into t (i,d) values (2,'two');"
b = freedbset(t)
dbopenset t,b, "select * from t order by d desc limit 1;"
call n("drow(t,b) - get row", dbrow(t,b), true)
call n("dbint(t,b,0)=2", dbint(t,b,0), 2)
call s("dbstring(t,b,1)='two''", dbstring(t,b,1), "two")
call n("drow(t,b) - get row", dbrow(t,b), false)
a = freedbset(t)
dbopenset t,a, "select * from t order by 1 limit 1;"
call n("drow(t,a) - get row", dbrow(t,a), true)
call n("dbint(t,a,0)=1", dbint(t,a,0), 1)
call s("dbstring(t,a,1)='one''", dbstring(t,a,1), "one")
call n("drow(t,a) - get row", dbrow(t,a), false)
# leave both seta open so that we can let dbclose close them
#
print "t,b,a = " + t + "," + b + "," + a
#
dbclose t
kill "testsuite2.db"
dbclose
kill "testsuite.db"
|