On Tuesday, April 3, 2018 at 6:21:38 AM UTC+1, Pranas Baliuka wrote:
Hello kdb gurus,
I’m total qbie and can’t figure out how to use basic tables in kdb+. I believe someone with some practical experience can solve the riddle on how to insert Dictionary to the table.
My attempt to create table with dictionary:
xxx:(
ext_attrs:()/ EXT_ATTRIBUTE
);
.u.upd:insert
Test code:
q)m:(847
1328`99!(“VWAP”;“Invalid quantity”;“50”))
q)m
847 | “VWAP”
1328| “Invalid quantity”
99 | “50”
Attempt to insert the dictionary to table:
q).u.upd[`xxx;m]
'mismatch
Result:
Failed with some kind of mismatch…
Can someone help me inserting dictionary into table?
If it is possible in q language would it be possible to perform from c.java?
Thanks ;)
P
Hi Pranas,
I believe the following will insert your dictionary into your table:
q)xxx:(ext_attrs:())
q).u.upd:insert
q)m:(847
1328`99!(“VWAP”;“Invalid quantity”;“50”))
q).u.upd[xxx;enlist[
ext_attrs]!enlist m]
,0
q)xxx
ext_attrs
847
1328`99!(“VWAP”;“Invalid quantity”;“50”)
As for the q language in c.java try:
.c.k(“.u.upd”,“xxx”,m)
where m is previously constructed following similar examples that can be found here:
http://code.kx.com/q/interfaces/java-client-for-q/
e.g. to publish to a kdb+ consumer, here a kdb+ ticker plant, use
// Assuming a remote schema of
// mytable:(time:timespan$();sym:
symbol$();price:float$();size:
long$())
Objectrow={new c.Timespan(),“SYMBOL”,new Double(93.5),new Long(300)};
c.k(“.u.upd”,“mytable”,row);
I hope this helps,
Julia