User`s guide
7 Functions — Alphabetical List
7-80
readall
Read every record in DatabaseDatastore
Syntax
data = readall(dbds)
Description
data = readall(dbds) retrieves data from the DatabaseDatastore object dbds in
the format specified using setdbprefs.
Examples
Read Every Record in a DatabaseDatastore
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);