13-6 使用 MATLAB對??庫??修改:另一種方?

FiHϥ SQL ROӹƮwiק~AMATLABƮwuc]ѤF@ǫOA㦳ק\AYp`ICƹWAoǫO̫]ONʧ@ন SQL ROAbg ODBC eƮwC]pGA SQL ܼAӴNϥΫe@`쪺kA|ı@ǡC

YnsWơAiHϥ insert OAШUCd C

Example 1: 13-PƮwX/insertData02.mcopyfile('score01.mdb', 'score02.mdb'); % N score01.mdb score02.mdb dsn = 'dsnScore02'; % ]wƨӷW١] score02.mdb^ logintimeout(5); % ]wճsƮwɶ conn = database(dsn, '', ''); % sƮw exec(conn, 'DELETE * from score'); % RҦ colNames={'studentId', 'studentName', 'overall'}; % sWƪW dataValues={'0001', '', 100}; % sWƹ insert(conn, 'score', colNames, dataValues); % [J@ cursor = exec(conn, 'select * from score'); cursor = fetch(cursor); newScore = cursor.data % ܧs final 쪺 close(cursor); % cursor close(conn); % ƮwsnewScore = '0001' '' [0] [NaN] [NaN] [NaN] [0] [100]

bWzdҤAڭ̨ϥ MATLAB insert OӷsW@ơA䤤 colNames wsWƩҥΨ쪺W١]SwWٷ|Ʈww]ȡ^A dataValues hOsƹ colNames ȡCpG dataValues O@ӯx}A insert |NC@C@ơA]iH@sWƵơAdҦpUG

Example 2: 13-PƮwX/insertData03.mcopyfile('score01.mdb', 'score02.mdb'); % N score01.mdb score02.mdb dsn = 'dsnScore02'; % ]wƨӷW١] score02.mdb^ logintimeout(5); % ]wճsƮwɶ conn = database(dsn, '', ''); % sƮw exec(conn, 'DELETE * from score'); % RҦ colNames={'studentId', 'studentName', 'overall'}; % sWƪW dataValues={'0001', '', 100; '0002', 'LF', 97}; % sWƹ insert(conn, 'score', colNames, dataValues); % [Jⵧ cursor = exec(conn, 'select * from score'); cursor = fetch(cursor); newScore = cursor.data % ܧs final 쪺 close(cursor); % cursor close(conn); % ƮwsnewScore = '0001' '' [0] [NaN] [NaN] [NaN] [0] [100] '0002' 'LF' [0] [NaN] [NaN] [NaN] [0] [ 97]

MATLAB ]ѤF@ update OAiHsƮwơAbUCdҤAYZjε80Aڭ̪Nվ㬰100G

Example 3: 13-PƮwX/updateData02.mcopyfile('score01.mdb', 'score02.mdb'); % N score01.mdb score02.mdb dsn = 'dsnScore02'; % ]wƨӷW١] score02.mdb^ logintimeout(5); % ]wճsƮwɶ conn = database(dsn, '', ''); % sƮw colNames={'final'}; % ݧs dataValues={100}; % s᪺ update(conn, 'score', colNames, dataValues, 'where final>=80'); % ]wiƬdߪ SQL RO sql = 'select studentName, final from score'; % ]w SQL RO cursor = exec(conn, sql); cursor = fetch(cursor); newScore = cursor.data % ܧs final 쪺 close(cursor); % cursor close(conn); % ƮwsnewScore = 'ū䬰' [100] '' [100] '' [ 77] '\F' [ 78] '}Z' [100] 'T' [100] '' [ 79] '' [ 77] '©p' [ 77] 'Ĭs' [ 78] 'ù' [ 77] 'LCz' [100]

dҩұoGM insertData01.m ۦPAbAحzC


MATLAB{]pGig