Passing variables in DolphinDB metaprogramming

23 Views Asked by At

Is it feasible to replace a specified value with a variable in metaprogramming? For example, I intend to replace where Date = 2015.01.15 with where Date = $(date), in which “date“ is a variable.

1

There are 1 best solutions below

0
On BEST ANSWER

You can refer to the following two methods:

1.Concatenate related strings;

2.Use the sql function as follows:

n=100;
t=table(2020.01.01 + 0..(n-1) as timestamp, rand(`IBM`MS`APPL`AMZN,n) as symbol, rand(10.0, n) as value)
d = 2020.01.01
sql(sqlCol("*"), t, <timestamp=d>).eval()

For details, see sql — DolphinDB 2.0 documentation.