Home › Forums › kdb+ › each-both creating a projection › Re: each-both creating a projection
-
The exec statement creates a list of lists – enclosing these in square brackets means kdb+ treats this as a singular item passed to your function. In order to treat the list as the first and second arguments respectively, you need apply:
q)tab:([]col1:`a`b`c;col2:1 2 3) q).my.func:{0N!(x;y;z);} q){.my.func[x;y;`field]}./:flip value exec col1,col2 from tab; (`a;1;`field) (`b;2;`field) (`c;3;`field)
In this case though, you can keep the entire operation contained in the qsql statement. kdb+ will extend the atomic symbol to match the length of the table columns:
q)exec .my.func'[col1;col2;`field]from tab; (`a;1;`field) (`b;2;`field) (`c;3;`field)