Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

有什么方法可以动态拼接多行脚本执行

在DolphinDB database GUI中,我要定义函数动态的拼接多行脚本来执行,请问有什么方法吗?

比如,如下图所示这种多行脚本,箭头的地方是变量,需要动态替换的:
eval_20200619185129.png

里面还有limit需要设置为变量,但如下所示我直接在select语句后面加limit变量:

n=100
select * from customInstruments limit n

执行这个语句会报错: constant integer expected after keyword limit。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

拼接动态sql语句可参考元编程教程(
https://gitee.com/dolphindb/T... ) , 上面例子可试试下面代码:

sym='ICL8'
dbName="dfs://future_0523"
n=50:100
sql(select=sqlCol("*"),from=loadTable(dbName,"CustomInstruments"),where=[<date=today()>,<CustomInstID=sym>],limit=n).eval()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...