Search code examples
kdb

kdb+/q: Prevent initialised tables from returning a comma


Consider the following example:

test:([] name:`symbol$(); secondColumn:`int$());
insert[`test;(`John;1)];
myvar:exec name from test;

Now myvar is now:

q)myvar
,`John

So to select the actual result, I have to do:

q)myvar[0]
`John

I understand this is because of the initialisation, so is there a way to make myvar contain the actual value immediately?


Solution

  • Array access with [0] or first is the correct way if you want an "atomic" variable.

    myvar:first exec name from test;