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

Categories

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

在DolphinDB中使用subscribeTable函数时,参数设置的问题

在DolphinDB中的subscribeTable函数使用时,只有tableName和handler两个参数是必须的,执行如下代码:

share streamTable(10000:0,`timestamp`temperature, [TIMESTAMP,DOUBLE]) as pubTable
share streamTable(10000:0,`ts`temp, [TIMESTAMP,DOUBLE]) as subTable
vtimestamp = 1..100
vtemp = norm(2,0.4,100)
tableInsert(pubTable,vtimestamp,vtemp)
topic1 = subscribeTable("pubTable",subTable)

返回如下错误:

2020.12.08 17:19:45.811: executing code ...
Syntax Error: [line #21] The function [subscribeTable] expects 5~12 argument(s), but the actual number of arguments is: 2

请问哪里出了问题?


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

1 Answer

0 votes
by (71.8m points)

subscribeTable的语法如下:

subscribeTable([server], tableName, [actionName], [offset=-1], handler, [msgAsTable=false], [batchSize=0], [throttle=1], [hash=-1], [reconnect=false], [filter], [persistOffset=false])

只有tableName和handler两个参数是必需的。其他所有参数都是可选参数。

用keyParam方式调用可以是2个参数,表示订阅会从当前行开始,只有当新数据进入发布表时才能订阅到数据,代码如下:

topic1 = subscribeTable(tableName="pubTable",handler=subTable)

如果不指定paramKey,那么要指定参数至少到Handler位置,表示订阅会从当前行开始,只有当新数据进入发布表时才能订阅到数据,代码如下:

topic1 = subscribeTable(,"pubTable",,,subTable)

subscribeTable函数更详细的使用方法可以参考:

https://gitee.com/dolphindb/Tutorials_CN/blob/master/streaming_tutorial.md


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

2.1m questions

2.1m answers

63 comments

56.5k users

...