Contents
function sqlite_test_bind_wrapping
clear all
close all
clc
dummy = mksqlite('version mex');
fprintf( '\n\n' );
mksqlite Version 2.5 build: 133, ein MATLAB Interface zu SQLite
(c) 2008-2017 by Martin Kortmann <mail@kortmann.de>
Andreas Martin <andimartin@users.sourceforge.net>
basierend auf SQLite Version 3.16.2 - http://www.sqlite.org
mksqlite verwendet:
- DEELX perl kompatible regex engine Version 1.3 (Sswater@gmail.com)
- BLOSC/LZ4 1.3.0-rc3.dev zur Datenkompression (Francesc Alted / Yann Collett)
- MD5 Message-Digest Algorithm (RFC 1321) Implementierung von Alexander Peslyak
Platform: PCWIN64, little endian
Create a database with some records
fprintf( 'Creating in-memory database...\n' );
mksqlite( 'open', ':memory:' );
mydata = { ...
'Gunther', 'Meyer', 'Munich', []; ...
'Holger', 'Michelmann', 'Garbsen', rand( 1, 10 ); ...
'Knuth', 'Almeroth', 'Wehnsen', 'coworker' ...
};
mksqlite( 'CREATE TABLE demo (Col_1, Col_2, Col_3, Data)' );
mksqlite( 'typedBLOBs', 1 );
mksqlite( 'param_wrapping', 1 );
mksqlite( 'INSERT INTO demo VALUES (?,?,?,?)', mydata' );
Creating in-memory database...
Test how mksqlite handles incomplete bind parameters
fprintf( 'Testing how mksqlite handles incomplete bind parameters... ' );
errcount = 0;
try
mksqlite( 'INSERT INTO demo VALUES (?,?,?,?)', mydata{1:end-1} );
catch
errcount = errcount + 1;
end
try
mksqlite( 'INSERT INTO demo VALUES (?,?,?,?)', mydata{1:3} );
catch
errcount = errcount + 1;
end
if errcount == 2
fprintf( 'succeeded.\n' );
else
fprintf( 'failed.\n' );
end
clear errcount
Testing how mksqlite handles incomplete bind parameters... succeeded.
Read back all records
fprintf( 'Restore BLOB records...\n\n' )
query = mksqlite( 'SELECT * FROM demo' );
fprintf( '---> Empty array: ' ), ...
query(1).Data
fprintf( '---> 10 random numbers between 0 and 1: ' ), ...
query(2).Data
fprintf( '---> Text: ' ), ...
query(3).Data
mksqlite( 'close' );
Restore BLOB records...
---> Empty array:
ans =
[]
---> 10 random numbers between 0 and 1:
ans =
Columns 1 through 5
0.779891717135834 0.042640451671982 0.746890700358599 0.775119053677523 0.707290276498143
Columns 6 through 10
0.222288200282980 0.937968491611349 0.298374412918052 0.692303584254582 0.634084332143748
---> Text:
ans =
coworker