Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.38执行sql语句有问题. #13

Closed
wangyingdong opened this issue Jul 19, 2011 · 4 comments
Closed

1.38执行sql语句有问题. #13

wangyingdong opened this issue Jul 19, 2011 · 4 comments
Assignees
Milestone

Comments

@wangyingdong
Copy link

sql语句如下;
StringBuffer sb = new StringBuffer("");
sb.append("if (select count(*) from CorpLogin where CorpID = " + corpWeb.getCorpID() + ") = 0 ");
sb.append(" insert into CorpLogin(corpID,WebLoginDate,WebLoginTimes) values (" + corpWeb.getCorpID() + ",getDate(),1)");
sb.append("else");
sb.append(" update CorpLogin set WebLoginDate =getDate(),WebLoginTimes=WebLoginTimes+1 where corpId =" + corpWeb.getCorpID() + "");
Sql sql = Sqls.create(sb.toString());
dao.execute(sql);
异常:
org.nutz.mvc.impl.processor.FailProcessor - Catch handle error
org.nutz.dao.DaoException: java.lang.RuntimeException: r u kidding me?! It is impossible!
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:74)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:178)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:169)

@zozoh
Copy link
Member

zozoh commented Jul 19, 2011

大哥,为啥不分成几个 SQL 写涅? 效率差很多吗? 这样反而更不好让 DBA 优化吧

@wangyingdong
Copy link
Author

呵呵。这句在1.37里是好的。

@wangyingdong
Copy link
Author

1.38 里
Sql sql = Sqls.create("select count(*) as c from corp a inner join web b on a.id = b.Corpid where a.id =1");
dao.execute(sql);

出错了,换成 fetchInt 就可以了
Sql sql = Sqls.fetchInt("select count(*) as c from corp a inner join web b on a.id = b.Corpid where a.id =1");
dao.execute(sql);

Wendal~兽:估计是因为没有加入默认callback

@zozoh
Copy link
Member

zozoh commented Jul 20, 2011

1.b.38 对 SQL 做了稍微严格的检查, 我认为如果未知类型,就直接执行而不抛错就是了
在 1.b.39 里改一下吧

@zozoh zozoh closed this as completed Jul 20, 2011
@zozoh zozoh reopened this Jul 20, 2011
zozoh added a commit that referenced this issue Jul 20, 2011
@ghost ghost assigned zozoh Jul 20, 2011
@zozoh zozoh closed this as completed Jul 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants