Question : How Do I Shorten Code in Q language?

Hi,

I am working with Q language to query a kdb+ database. I convert my query into a URL and paste it into Explorer address to get my results. My queries have become too big to fit into the URL. I would like to shorten the code as much as I can. My idea was assigning pieces of code to a string and then using the string variable name instead of the code in several locations.

For example:
chars: ".k3.tl .df.exec[`TXSOR_G1_HIST_PROD;(""1 first select f[extra, 'OP_TypeOfDest'] from order "")]"
--Now execute the code inside a string (I don't actually know how to do this)

Does anyone know how to execute code inside a string? Or execute something like: code & variableContainingAString & code

Any other tips on how to shorten the code are welcome.

Thanks!
(One piece of my code is below)
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
f1:{[date] .k3.tl .df.exec[`TXC_E_HIST_PROD;("select OrdersSent:count OrderQty, OrdersExecuted:sum  CalcCumQty>0.0, SharesSent:sum OrderQty,  SharesExecuted:sum CalcCumQty by date, ExDestination from order where date=?, PARENT_OID in ?";(.util.dateq2k date; (OrderIDTable date)`OrderID))]};
 
 
f2:{[date] .k3.tl .df.exec[`TXC_I_HIST_PROD;("select OrdersSent:count OrderQty, OrdersExecuted:sum  CalcCumQty>0.0, SharesSent:sum OrderQty,  SharesExecuted:sum CalcCumQty by date, ExDestination from order where date=?, PARENT_OID in ?";(.util.dateq2k date; (OrderIDTable date)`OrderID))]};
 
 
t1: raze f1 each 2008.11.17 + til 5; 
t2: raze f2 each 2008.11.17 + til 5;
 
`ExDestination`date xasc select OrdersSent:sum OrdersSent, OrdersExecuted:sum OrdersExecuted, SharesSent:sum SharesSent, SharesExecuted:sum SharesExecuted by date, ExDestination from (0! t1),(0! t2)
Open in New Window Select All

Answer : How Do I Shorten Code in Q language?

I've just looked at the docs and there is odbc access to kdb. So you may not need q at all just interface vba to kdb+ via odbc driver

I believe this will work for you very nicely as long as you know vba well. Java is an option. With odbc you can use any language you like . Maybe even matlab for all I know!
Random Solutions  
 
programming4us programming4us