如何在update中动态传参,包括复杂表达式

update语句中,如何将set 后的语句动态传参,例如 update quote set fname = ufunc(k), 其中fname是变量,ufunc是自定义函数,k是外部变量,如何实现?

请先 登录 后评论

1 个回答

Shena Mao

可以参考下面的例子,sqlUpdate和sqlColAlias连用来解决。更多用法可以参照元编程:https://www.dolphindb.cn/cn/help/200/Objects/Metaprogramming.html

t1=table(`A`A`B`B as symbol, 2021.04.15 2021.04.16 2021.04.15 2021.04.16 as date, 12 13 21 22 as price)
b = `price
c = t1.price
def ufunc(b){
 return b+1}
sqlUpdate(t1, sqlColAlias(makeCall(ufunc,c),b)).eval()
t1


请先 登录 后评论
  • 1 关注
  • 0 收藏,927 浏览
  • ricecake 提出于 2022-01-06 15:48