Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

fetch

Request data from Kx Systems, Inc. kdb+ databases

Syntax

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

Arguments

k

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

ksql

The Kx Systems, Inc. kdb+ command.

p1,p2,p3

Input parameters for the ksql command.

Description

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.

Examples

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?