tableInsert报错The value type of the input dictionary must be ANY.

为什么在dolphindb中使用tableInsert时,当两个数据类型都是int时提示The value type of the input dictionary must be ANY,有一个是string的时候就可以正常插入,代码如下:

//有问题
colName = ["Name", "Age"]
colType = ["int", "int"]
t1 = table(100:0, colName, colType)
t1.tableInsert(dict(`Name`Age, [22, 22]))

//正常
colName = ["Name", "Age"]
colType = ["string", "int"]
t1 = table(100:0, colName, colType)
t1.tableInsert(dict(`Name`Age, ["Tom", 22]))
请先 登录 后评论

1 个回答

Jax Wu

使用(1, 3)表示tuple,使用[1, 3]表示array。
如果有一个string和一个int,不同类型的,系统就当作tuple处理了。
上述例子中,如果是想往t1中写入数据,可以使用下面的代码:

colName = ["Name", "Age"]
colType = ["int", "int"]
t1 = table(100:0, colName, colType)
t1.tableInsert(22, 22)

colName = ["Name", "Age"]
colType = ["string", "int"]
t1 = table(100:0, colName, colType)
t1.tableInsert(`Tom, 22)
请先 登录 后评论