This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Request data from Kx Systems, Inc. kdb+ databases


d = fetch(k,ksql)
d = fetch(k,ksql,p1,p2,p3)



Kx Systems®, Inc. kdb+ connection object created with kx.


The Kx Systems, Inc. kdb+ command.


Input parameters for the ksql command.


d = fetch(k,ksql) returns data from a Kx Systems, Inc. kdb+ database in a MATLAB® structure where k is the Kx Systems, Inc. kdb+ object and ksql is the Kx Systems, Inc. kdb+ command. ksql can be any valid kdb+ command. The output of the fetch function is any data resulting from the command specified in ksql.

d = fetch(k,ksql,p1,p2,p3) executes the command specified in ksql with one or more input parameters, and returns the data from this command.


Run the following command from a DOS prompt to specify the port number 5001:

q tradedata.q -p 5001 

Connect to a Kx Systems, Inc. server using IP address 'localhost' and port number 5001:

k = kx('localhost',5001); 

Retrieve data using the command 'select from trade':

   d = fetch(k,'select from trade');
   d =           
			sec: {5000x1 cell}
       price: [5000x1 double]
      volume: [5000x1 int32]
    exchange: [5000x1 double]
        date: [5000x1 double]

Retrieve data, passing an input parameter 'ACME' to the command 'select from trade':

d = fetch(k,'totalvolume','ACME');  
d = 
      volume: [1253x1 int32]    

This is the total trading volume for the security ACME in the table trade. The function totalvolume is defined in the sample Kx Systems, Inc. kdb+ file, tradedata.q.

See Also

| |

Was this topic helpful?