日期:2014-05-18  浏览次数:20564 次

SQLITE插入语句错误
SQL code

IF NOT EXISTS(SELECT * FROM Company WHERE MAC='aa:22:cc:22:ee:ff')
                                                            INSERT INTO Company(Mac,CompanyId,CompanyName,FtpParameter) Values('aa:22:cc:22:ee:ff','00101','aabbcc','192.168.123.11|21|abc|abc')



为什么提示:
Error message: SQL script is wrong

------解决方案--------------------
SQL code

create table #t(Mac varchar(50),CompanyId  varchar(50),CompanyName varchar(50),FtpParameter  varchar(50))

IF NOT EXISTS(SELECT * FROM #t WHERE MAC='aa:22:cc:22:ee:ff')
INSERT INTO #t(Mac,CompanyId,CompanyName,FtpParameter) Values('aa:22:cc:22:ee:ff','00101','aabbcc','192.168.123.11|21|abc|abc')


select * from #t 

Mac                                                CompanyId                                          CompanyName                                        FtpParameter
-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- --------------------------------------------------
aa:22:cc:22:ee:ff                                  00101                                              aabbcc                                             192.168.123.11|21|abc|abc

(1 行受影响)
drop table #t

---没问题

------解决方案--------------------
估计就是类型的问题。。。楼主你在写语句的时候转换下试试
------解决方案--------------------
探讨
SQL codecreatetable #t(Macvarchar(50),CompanyIdvarchar(50),CompanyNamevarchar(50),FtpParametervarchar(50))IFNOTEXISTS(SELECT*FROM #tWHERE MAC='aa:22:cc:22:ee:ff')INSERTINTO #t(Mac,CompanyId,CompanyNam¡­

------解决方案--------------------
探讨
换成下面这个也是不行,
SQL codeIFNOTEXISTS(SELECT*FROM CompanyWHERE MAC='aa')INSERTINTO Company
(Mac,CompanyId,CompanyName,FtpParameter)Values('aa','aabbcc','abc')

是不是我这个SQLite Developer出问题了,但是简单的select语句却可以执行啊?