User`s guide

cursor.fetch
7-41
setdbprefs('FetchInBatches’,'yes')
setdbprefs('FetchBatchSize’,'2')
conn = database('dbtoolboxdemo','','');
curs = exec(conn,'select * from productTable');
curs = fetch(curs);
A = curs.Data
A =
[ 9] [125970] [1003] [13] 'Victorian Doll'
[ 8] [212569] [1001] [ 5] 'Train Set'
[ 7] [389123] [1007] [16] 'Engine Kit'
[ 2] [400314] [1002] [ 9] 'Painting Set'
[ 4] [400339] [1008] [21] 'Space Cruiser'
[ 1] [400345] [1001] [14] 'Building Blocks'
[ 5] [400455] [1005] [ 3] 'Tin Soldier'
[ 6] [400876] [1004] [ 8] 'Sail Boat'
[ 3] [400999] [1009] [17] 'Slinky'
[10] [888652] [1006] [24] 'Teddy Bear'
cursor.fetch internally retrieves data in increments of two rows at a time. Tune the
FetchBatchSize setting depending on the size of the result set you expect to fetch.
For example, if you expect about a 100,000 rows in the output, a batch size of 10,000 is
a good starting point. The larger the FetchBatchSize value, the fewer trips between
Java and MATLAB, and the memory consumption is greater for each batch. The optimal
value for FetchBatchSize is decided based on several factors like the size per row
being retrieved, the Java heap memory value, the driver’s default fetch size, and system
architecture, and hence, can vary from site to site.
If 'FetchInBatches' is set to 'yes' and the total number of rows fetched is less than
'FetchBatchSize', MATLAB shows a warning message and then fetches all the rows.
The message is: Batch size specified was larger than the number of rows fetched.
You can exercise a row limit on the final output even when the FetchInBatches setting
is 'yes'.
setdbprefs('FetchInBatches’,'yes')
setdbprefs('FetchBatchSize’,'2')
curs = exec(conn,'select * from productTable');
curs = fetch(curs,3);
A = curs.Data
A =