Empty table declaration

605 views
Skip to first unread message

Q_developer

unread,
Jun 4, 2012, 4:29:53 AM6/4/12
to personal...@googlegroups.com
Hi ,
 
I have declared an empty table as t:([] c1:`int$();c2:`int$())
Now I want to insert compound column data like
c1     c2
--       ---
10     20 30
the statement `t insert (10; 20 30) didn't work.But if I declare the table without specifying null list of the type,then it is working.
i.e  t:([] c1:`int$();c2:()) works.
Is there any way to fix the type for the columns of the general lists before inserting first item.
 
Regards,

Charles Skelton

unread,
Jun 4, 2012, 5:51:21 AM6/4/12
to personal...@googlegroups.com
no, () is an empty list with type 0 - there's no way to embed the type of a nested list there.
Also note that
meta t
will take the type of the first element, and assume that the remaining elements are of the same type as that element; this is not always correct. e.g.

q)meta ([]a:(1 2;`a`b))
c| t f a
-| -----
a| J 



--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
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.

Sean

unread,
Jun 4, 2012, 11:29:16 AM6/4/12
to Kdb+ Personal Developers
there is a hacking way I am using, leave it to be general list when
firstly define the table, and then insert a sample data. in that way,
q will recognize the table schema by checking the first record.

here "I" means list of integers, this can be applied to "C" (string)
as well

q)a:([]c1:`int$();c2:())
q)insert [`a; (1;1 2)]
,0
q)meta a
c | t f a
--| -----
c1| i
c2| I
q)

Felix Lungu

unread,
Jun 5, 2012, 2:45:12 AM6/5/12
to personal...@googlegroups.com
that's no hacking. it is the way to define a column with nested data.
Reply all
Reply to author
Forward
0 new messages