Reputation: 615
I am storing strings in a list under variable name res. Next, I construct a query that will look into the list of strings. However it seems like the variable is not being read.
This is what I mean:
q) hdl: (to a port)
q) res: `string1`string2`string3
**q) ans: hdl"select count i by date,sym from trade where date=xxx, sym in `res"**
When I execute the command, I always get an empty result set. I know that the resultset cannot be empty. So how can I fix my query (in bold) to return results?
Please note I am performing the task from a q session in unix box.
Upvotes: 3
Views: 1966
Reputation: 1186
Something like the following will work:
ans:hdl({select count i by date,sym from trade where date=xxx, sym in x};res)
@mollmerx is correct about having res defined locally and not on the remote process, although my query above is preferable to a functional select.
Upvotes: 6
Reputation: 648
You are setting res on the local process. You could fix this simply by doing:
hdl"res:`string1`string2`string3"
I think you will also need to remove the backtick from res
in your select query.
Another suggestion is to not send a q string through the handle. You can continue to set res locally, but then do something similar to this:
hdl(?;`trade;((=;`date;xxx);(in;`sym;enlist res));0b;enlist[`cnt]!enlist(count;`i))
Upvotes: 2