2 newbie questions on KDB tables, stuff I could not find in q-for-mortals and kdbfaq:
- When inserting into KDB table I often have columns whose values are null. For e.g. if I have columns a, b, c and d I only insert to a & b at times or a & c etc. But KDB is not letting me do that - I keep getting error. Is there a way to fix this?
- How do I give a default value to a column if not explicitly inserting? This as you can see is a direct corollary of question 1.
Thanks!
Hi,
Inserts where columns contain null values should work:
q)t:( a:1 2; b:3 4.; c:p
o)
q)t insert ([] a:1 2; c:
il) 2 3 q)
t insert ( a:1 2; b:1.1 2.2)
4 5
q)`t insert ( b:1.1 2.2)
6 7
q)t
a b c
1 3 p
2 4 o
1 i
2 l
1 1.1
2 2.2
1.1
2.2
Have you got an example for some code that was giving an error?
The carat^ symbol allows replacing nulls easily, for example:
q)update 9^a, 9.99^b, `ggg^c from t
a b c
1 3 p
2 4 o
1 9.99 i
2 9.99 l
1 1.1 ggg
2 2.2 ggg
9 1.1 ggg
9 2.2 ggg
Either update the data as your inserting or as your retrieving.
Regards,
Ryan
--
TimeStored.com - KDB+ Training, Consulting, Software
On 15/09/2013 19:24, kdb newb wrote:
2 newbie questions on KDB tables, stuff I could not find in q-for-mortals and kdbfaq:
- When inserting into KDB table I often have columns whose values are null. For e.g. if I have columns a, b, c and d I only insert to a & b at times or a & c etc. But KDB is not letting me do that - I keep getting error. Is there a way to fix this?
- How do I give a default value to a column if not explicitly inserting? This as you can see is a direct corollary of question 1.
Thanks!
–
You received this message because you are subscribed to the Google Groups “Kdb+ Personal Developers” group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.
To post to this group, send email to personal-kdbplus@googlegroups.com.
Visit this group at http://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/groups/opt_out.