newbie question: 'rank error on table insert insert

311 views
Skip to first unread message

Dodong Juan

unread,
May 15, 2012, 9:30:39 PM5/15/12
to personal...@googlegroups.com
trying to insert a record to a table:

q)`:/db/data/ set ([] nodeid:12345; object:`$"hithere" ti:09:30:00)
`rank

what does the `rank error mean ..?

Thanks

rolf

unread,
May 15, 2012, 11:13:22 PM5/15/12
to personal...@googlegroups.com
your syntax stinks.

([]nodeid:enlist 12345; object:enlist`$"hithere";ti:enlist 09:30:00)

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/personal-kdbplus/-/kmCkauyj0i8J.
To post to this group, send email to personal...@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.

Aaron Davies

unread,
May 16, 2012, 8:09:10 AM5/16/12
to personal...@googlegroups.com
>> q)`:/db/data/ set ([] nodeid:12345; object:`$"hithere" ti:09:30:00)
>> `rank
>
> your syntax stinks.
>
> ([]nodeid:enlist 12345; object:enlist`$"hithere";ti:enlist 09:30:00)

actually q will vector-extend any atoms in a table literal, as long as there's at least one actual vector to give the count

q)([]nodeid:enlist 12345;object:`hithere;ti:09:30:00)
nodeid object ti
-----------------------
12345 hithere 09:30:00
q)([]nodeid:12345;object:enlist`hithere;ti:09:30:00)
nodeid object ti
-----------------------
12345 hithere 09:30:00
q)([]nodeid:12345;object:`hithere;ti:enlist 09:30:00)
nodeid object ti
-----------------------
12345 hithere 09:30:00
q)

(in a keyed table, there must be at least one vector in the keys and one in the values:

q)([nodeid:12345;nodetype:1]object:enlist`hithere;ti:09:30:00)
'rank
q)([nodeid:enlist 12345;nodetype:1]object:enlist`hithere;ti:09:30:00)
nodeid nodetype| object ti
---------------| ----------------
12345 1 | hithere 09:30:00
q)

)

Tom Martin

unread,
May 16, 2012, 8:40:58 AM5/16/12
to Kdb+ Personal Developers
you're missing a semicolon after "hithere" so the table has only 2
columns rather than 3, hence the rank error.
Reply all
Reply to author
Forward
0 new messages