【发布时间】:2019-01-10 15:24:51
【问题描述】:
我正在编写一个函数来从数据库中选择所有以字母“A”开头的符号,然后是“B”,直到字母“Z”。我有一个虚拟表,其中包含 3 个字符,如下所示...
t:([]symbol:`A`App`B`Bapp`C`Capp; price:104.3 124.3 134.2 103.4 402.7 209.8; ID:1 2 3 4 5 6)
还有一个函数可以从表中选择符号看起来像 x...
fetch:{[x;y]select from x where symbol like y}
然后我为每个字母调用该函数并插入到一个新表中...
fetchedA:h (`fetch; `t; "A*")
fetchedB:h (`fetch; `t; "B*")
fetchedC:h (`fetch; `t; "C*")
新的空表以及 upsert 函数...
newNormData:([]symbol:`$(); price:`float$(); ID:`int$())
newNorm:{[x] `newNormData upsert x}
h (`newNorm; fetchedA)
h (`newNorm; fetchedB)
h (`newNorm; fetchedC)
我不想为每个服务器进行 26 次函数调用,我想进行 1 次调用来遍历字母表中的每个字符。在 kdb/q 中执行此操作的正确方法是什么?
【问题讨论】:
标签: kdb