Dynamically pass parameters (including complex expressions) to update clause using DolphinDB?

18 views Asked by At

How can I dynamically pass parameters to clause after set in DolphinDB? For example, update quote set fname = ufunc(k), where fname is a variable ufunc is a custom function, and k is an external variable. How should I implement it?

1

There are 1 answers

0
dbaa9948 On

You can refer to the following example, use function sqlUpdate with sqlColAlias. More examples can be found in the link below about Meta programming.

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