User`s guide

read
7-77
close(dbds)
Retrieve Data and Database Information Using a Row Count
The default output data type of any datastore is a table. Set the database preference
for the data return format 'DataReturnFormat' to table for consistency across data
types.
setdbprefs('DataReturnFormat','table')
Create a database connection conn using the native ODBC interface with Windows
Authentication. This code assumes you are connecting to a Microsoft SQL Server
database with the data source named MS SQL Server Auth. MS SQL Server Auth
contains the table named productTable with 15 product records.
conn = database.ODBCConnection('MS SQL Server Auth','','');
Create a DatabaseDatastore object dbds using the database connection conn and
SQL query sqlquery. This SQL query retrieves all products from the product table
productTable ordered by product number.
sqlquery = ['select * from [toy_store].[dbo].[productTable] '...
'order by productNumber'];
dbds = datastore(conn,sqlquery);
Read the first five records in the DatabaseDatastore object dbds and retrieve
information info about the database.
[data,info] = read(dbds,5)
data =
productNumber stockNumber supplierNumber unitCost productDescription
_____________ ___________ ______________ ________ __________________
1.00 400345.00 1001.00 14.00 'Building Blocks'
2.00 400314.00 1002.00 9.00 'Painting Set'
3.00 400999.00 1009.00 17.00 'Slinky'
4.00 400339.00 1008.00 21.00 'Space Cruiser'
5.00 400455.00 1005.00 3.00 'Tin Soldier'
info =
datasource: 'MS SQL Server Auth'
offset: 0
data contains the query results. The row count argument 5 determines the number of
records read returns. The structure info contains the data source name datasource
and current cursor position offset.