You could also use set along with an each to automatically split your table into separate tables, something like this (using a dummy trades table):<o:p></o:p>
<o:p> </o:p>
q)exec distinct sym from trades<o:p></o:p>
u#
ORCLYHOO
AAPLIBM
NOKCSCO
MSFTDELL
GOOG<o:p></o:p>
q){sv[;x,
trades] set select from trades where sym=x}each exec distinct sym from trades<o:p></o:p>
ORCL.trades
YHOO.tradesAAPL.trades
IBM.tradesNOK.trades
CSCO.tradesMSFT.trades
DELL.trades`GOOG.trades<o:p></o:p>
q)ORCL.trades<o:p></o:p>
time sym src price size<o:p></o:p>
-------------------------------------------------<o:p></o:p>
2017.11.06D08:00:53.319000000 ORCL N 32.23 1099<o:p></o:p>
2017.11.06D08:02:31.085000000 ORCL O 32.18 514<o:p></o:p>
2017.11.06D08:04:51.572000000 ORCL O 32.23 25<o:p></o:p>
2017.11.06D08:06:07.993000000 ORCL L 32.21 965<o:p></o:p>
2017.11.06D08:19:32.241000000 ORCL N 32.22 5070<o:p></o:p>
2017.11.06D08:33:33.336000000 ORCL N 32.18 190<o:p></o:p>
..<o:p></o:p>
<o:p> </o:p>
Here sv is used to generate the table name in each case as a symbol, which is then used by set as a global variable name for the given table<o:p></o:p>
<o:p> </o:p>
Depending on your use case, it may make more sense to do this when loading data or receiving real time data if this is the case, there are likely open source frameworks available that can ease this process.<o:p></o:p>
<o:p> </o:p>
Regards<o:p></o:p>
Jonathon<o:p></o:p>
<o:p> </o:p>
From: personal-kdbplus@googlegroups.com [mailto:personal-kdbplus@googlegroups.com] On Behalf Of thomas.smyth@aquaq.co.uk
Sent: 06 November 2017 09:23
To: Kdb+ Personal Developers <personal-kdbplus@googlegroups.com>
Subject: [personal kdb+] Re: How to create table dynamically?<o:p></o:p>
<o:p> </o:p>
Hi,<o:p></o:p>
<o:p> </o:p>
Sounds like you want to name a table based on a symbol you have created. In order to do this you need to use ‘set’:<o:p></o:p>
<o:p> </o:p>
`tbl001 set (sym:())<o:p></o:p>
<o:p> </o:p>
Please let us know if this resolves your issue.<o:p></o:p>
<o:p> </o:p>
Regards,<o:p></o:p>
Thomas Smyth<o:p></o:p>
AquaQ Analytics<o:p></o:p>
<o:p> </o:p>
On Monday, 6 November 2017 07:12:22 UTC, hzad…@gmail.com wrote:<o:p></o:p>
Hi, Masters:<o:p></o:p>
I need to create tables based on current day’s stocks. For example, Nov 1, there’re 5 stocks(001~005), and the tables should be created as tbl001~tbl005; and Nov 3, there’re 10 stocks(001~010), the tables should be created as (tbl001~tbl010).<o:p></o:p>
So far, I can generate the tablename according to the stock name. But how to pass the tablename to KDB+ to create table?<o:p></o:p>
<o:p> </o:p>
Regards<o:p></o:p>
Zheng<o:p></o:p>
–
Submitted via Google Groups