以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://www.weistock.com/bbs/index.asp) -- 高级功能研发区 (http://www.weistock.com/bbs/list.asp?boardid=5) ---- 在符合if条件下才进行数据库插入语句,为什么不符合if条件,仍会执行该数据库相关语句? (http://www.weistock.com/bbs/dispbbs.asp?boardid=5&id=50741) |
|
-- 作者:淡月映梅 -- 发布时间:2013/4/7 17:39:38 -- 在符合if条件下才进行数据库插入语句,为什么不符合if条件,仍会执行该数据库相关语句? DATABASE(\'driver=SQL Server;Server=192.168.0.105;DATABASE=hkysignal;UID=sa;PWD=123\'); update_sql:=\'update signal set ordertime=\' & numtostr(time,0) & \',orderprice=\' & numtostr(c,0) & \' where ID=(select MAX(id) from signal)\'; if c>5555 then begin dbtable(\'insert into signal(stockdate,direction,operation) values(getdate(),"S","buyshort")\'); dbexecute(update_sql); end; 分条件进行插入语句,为什么上面的句子明明价格不会大方于5555,仍会执行插入语句 ?
|
|
-- 作者:王锋 -- 发布时间:2013/4/7 20:48:46 -- if c>5555 then begin
dbtable(\'insert into signal(stockdate,direction,operation) values(getdate(),"S","buyshort")\');
dbexecute(update_sql);
end;
在这里加上调试语句后看看为什么
|
|
-- 作者:淡月映梅 -- 发布时间:2013/4/8 18:21:11 -- ??什么意思呀?上面的语句仍是有进行插入数据库的。 [此贴子已经被作者于2013-4-8 18:22:10编辑过]
|
|
-- 作者:王锋 -- 发布时间:2013/4/8 22:00:46 -- 加上日志不会吗? 日志上会清楚的告诉你,为什么你提出这个帖子的疑问。 我们也不是神仙啊 |
|
-- 作者:rushtaotao -- 发布时间:2013/4/8 22:36:57 --
[此贴子已经被作者于2013-4-8 22:38:09编辑过]
|
|
-- 作者:淡月映梅 -- 发布时间:2013/4/9 12:00:46 -- ![]() cond:c>5555; DATABASE(\'driver=SQL Server;Server=192.168.0.105;DATABASE=hkysignal;UID=sa;PWD=123\'); if cond then begin debugfile(\'d:\\temp.txt\',\'testvalue:= %2f\',cond); dbexecute(\'insert into signal(stockdate) values(getdate())\'); debugfile(\'d:\\temp.txt\',\'testvalue2:= %2f\',cond); end; 用dbtable的原因是它能实现字符串的数据库插入动作。而dbexecute不行
|