Windows XP
Firebird 3.0.0
Firebird ODBC 2.0.4
Active Tcl 8.6.4.1
DSN 設定(和之前一樣):
TDBC-ODBC and Firebird ODBC
package require tdbc::odbc
set connStr "DSN=Firebird DSN; UID=danilo; PWD=danilo;"
tdbc::odbc::connection create db $connStr
set statement [db prepare {create table person (id integer, name varchar(40))}]
$statement execute
$statement close
set statement [db prepare {insert into person values(1, 'leo')}]
$statement execute
$statement close
set statement [db prepare {insert into person values(2, 'yui')}]
$statement execute
$statement close
set statement [db prepare {SELECT * FROM person}]
$statement foreach row {
puts [dict get $row ID]
puts [dict get $row NAME]
}
$statement close
set statement [db prepare {drop table person}]
$statement execute
$statement close
db close
比較好的地方是,最後 drop table 不需要使用第二個 script 執行才行,之前會那樣做是因為如果直接 drop (可能會)有錯誤訊息而無法刪除,但是看起來 Firebird 3.0.0 已經和其它的資料庫行為一致了。
沒有留言:
張貼留言