请问一下目前DolphinDB database是否有办法动态操作一张内存表,即把update语句写成动态的。目前我们前端会将数据表名传回来,但是我试了几种办法都不能直接更新指定的内存表,有什么解决方法么?
比如下面代码:
table1=table(1..6 as id,2..7 as v, 3..8 as v1, 4..9 as v2, 5..10 as v3 );
share table1 as t1;
tableName ="t1";
update!(tableName, `v, 666);
执行后报错:
Read only object or object without ownership can't be applied to mutable function update!
再比如下面代码:
updateSql = "update t1 set v = 999;";
parseExpr(updateSql).eval;
执行后报错:
Invalid expression: update t1 set v=999;
DolphinDB中有个update!可以就地更新表中的列,它的语法是
其中的参数table是DolphinDB中Table类型的表。上面代码的问题是给table赋值了一个字符串,可以用objByName转换一下,代码如下:
更多有关动态更新内存表的内容请参阅元编程教程 2.1节。