我正在使用 phonegap 访问电话数据库。但是我的创建过程每次都会调用带有错误代码的错误例程:5 和消息:non an error
?
难道不能在一个事务中执行多个sql语句吗?
SQLite Expert 找不到语法错误...
createDB: function(error, success) {
if(typeof error != 'function') error = this.errorDB;
if(typeof success != 'function') success = this.successDB;
sql = "DROP TABLE IF EXISTS `boiler`; "
+"CREATE TABLE IF NOT EXISTS `boiler` ( "
+" `id` int NOT NULL, `object` int NOT NULL, `number` varchar(100) NOT NULL, "
+" `volume` double DEFAULT NULL, `brand` varchar(100) DEFAULT NULL, `year` year(4) DEFAULT NULL, "
+" `price_before` float NOT NULL DEFAULT '0', `price_after` float NOT NULL DEFAULT '0', `description` TEXT DEFAULT NULL, "
+" `img1` varchar(200) DEFAULT NULL, `img2` varchar(200) DEFAULT NULL, `img3` varchar(200) DEFAULT NULL, "
+" `img4` varchar(200) DEFAULT NULL, `img5` varchar(200) DEFAULT NULL, `img6` varchar(200) DEFAULT NULL, "
+" `img7` varchar(200) DEFAULT NULL, `img8` varchar(200) DEFAULT NULL, `img9` varchar(200) DEFAULT NULL, "
+"PRIMARY KEY (`id`)); "
+"DROP TABLE IF EXISTS `counter`; "
+"CREATE TABLE IF NOT EXISTS `counter` ( "
+" `number` varchar(100) NOT NULL, `object` int NOT NULL, `type` tinyint NOT NULL DEFAULT '0', "
+" `value` double DEFAULT NULL, `access` varchar(100) DEFAULT NULL, "
+"PRIMARY KEY (`number`)); "
+"DROP TABLE IF EXISTS `link`; "
+"CREATE TABLE IF NOT EXISTS `link` ( "
+" `id` int NOT NULL, `boiler` int NOT NULL, `name` varchar(100) DEFAULT NULL, "
+" `units` tinyint DEFAULT NULL, `price` float NOT NULL DEFAULT '0', "
+"PRIMARY KEY (`id`)); "
+"DROP TABLE IF EXISTS `manager`; "
+"CREATE TABLE IF NOT EXISTS `manager` ( "
+" `id` int NOT NULL, `company` varchar(100) DEFAULT NULL, `name` varchar(100) NOT NULL, "
+" `phone` varchar(15) DEFAULT NULL, "
+"PRIMARY KEY (`id`)); "
+"DROP TABLE IF EXISTS `object`; "
+"CREATE TABLE IF NOT EXISTS `object` ( "
+" `id` int NOT NULL, `state` tinyint NOT NULL DEFAULT '0', `user` varchar(50) DEFAULT NULL, "
+" `date` char(15) DEFAULT NULL, `street` varchar(100) DEFAULT NULL, `number` varchar(16) DEFAULT NULL, "
+" `zip` char(5) DEFAULT NULL, `city` varchar(100) DEFAULT NULL, `manager` int NOT NULL DEFAULT '0', "
+" `units` int NOT NULL DEFAULT '0', "
+"PRIMARY KEY (`id`));";
console.log(sql);
this.DB.transaction(function (tx) { tx.executeSql(sql); }, error, success);
},