winlong 发表于 2007-12-2 12:27:01

在存储过程中使用case语句出错,死活都无法实现!

看下面的存储过程: <br/>ALTER &nbsp; PROCEDURE &nbsp; pos01."sp_cost_matuse" <br/>( &nbsp; in &nbsp; @nf &nbsp; integer,in &nbsp; @yf &nbsp; integer,in &nbsp; @rq1 &nbsp; date,in &nbsp; @rq2 &nbsp; date,@cjbh &nbsp; char(4),@cplb &nbsp; char(6),@lbbh &nbsp; char(6),in &nbsp; @andcheck &nbsp; char(1)) <br/>AS <br/>BEGIN <br/>--创建临时表 <br/>Create &nbsp; Table &nbsp; #acc( <br/>cpbh &nbsp; char(15), <br/>sl &nbsp; numeric(15,4), <br/>sl_b &nbsp; numeric(15,4), <br/>cbje &nbsp; money) <br/>--统计 <br/>CASE @cplb <br/>WHEN &nbsp; 'all' &nbsp; THEN <br/>// Insert &nbsp; into &nbsp; #acc(cpbh,sl,sl_b,cbje) <br/>// Select &nbsp; cpbh0,sum(sl),sum(sl_b),sum(cbje) &nbsp; From &nbsp; pjnr1 &nbsp; a,pjnr2 &nbsp; b &nbsp; where &nbsp; (a.pjlb &nbsp; = &nbsp; b.pjlb &nbsp; and &nbsp; a.pjdh &nbsp; = &nbsp; b.pjdh) &nbsp; and &nbsp; (a.rq &nbsp; &gt; = &nbsp; :@rq1 &nbsp; and &nbsp; a.rq &nbsp; &lt;= &nbsp; :@rq2) &nbsp; and &nbsp; (a.pjlb &nbsp; = &nbsp; 'C') &nbsp; <br/>WHEN &nbsp; 'cpsx' &nbsp; THEN <br/>// Insert &nbsp; into &nbsp; #acc(cpbh,sl,sl_b,cbje) <br/>// Select &nbsp; cpbh0,sum(sl),sum(sl_b),sum(cbje) &nbsp; From &nbsp; pjnr1 &nbsp; a,pjnr2 &nbsp; b &nbsp; where &nbsp; (a.pjlb &nbsp; = &nbsp; b.pjlb &nbsp; and &nbsp; a.pjdh &nbsp; = &nbsp; b.pjdh) &nbsp; and &nbsp; (a.rq &nbsp; &gt; = &nbsp; :@rq1 &nbsp; and &nbsp; a.rq &nbsp; &lt;= &nbsp; :@rq2) &nbsp; and &nbsp; (a.pjlb &nbsp; = &nbsp; 'C') &nbsp; <br/>END &nbsp; CASE; <br/>END <br/><br/>我不知道这样的存储过程有什么问题,sql &nbsp; anywhere &nbsp; 8的帮助文档看了无数遍,也没有查出来有什么问题。但每当存盘的时候,总是报错:ASA &nbsp; error &nbsp; -131: &nbsp; Syntax &nbsp; error &nbsp; near &nbsp; 'CASE &nbsp; @cplb &nbsp; on &nbsp; line &nbsp; 12'。我不明白这样写case语句有什么问题?真的是急死人了。

ehxz 发表于 2007-12-4 16:34:49

ASA的存储没用过,不过报错的行不一定是真正出错的行。
页: [1]
查看完整版本: 在存储过程中使用case语句出错,死活都无法实现!

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com