哪位熟悉存储过程的大哥帮看一下这个存储过程
hzdzd 2003-09-23 03:34:28 在SQL Server2000的查询分析器中执行该语句时,会有四个错误提示。哪位大哥能帮我修正一下,谢谢!(因为整个语句太长,所以切分成两部分,待会在回复中发后半部分):
create procedure p_get_reciept @app_type_code char(3), @flow_num integer, @step_no smallint,@tache_code char(3),@app_no varchar(20), @post_or_name varchar(8) output
as
declare @gowhere_exp varchar(255)
declare @exp_col_value_str varchar(30)
declare @place_mark smallint
declare @exp_result integer
declare @relation_flag char(1)
select @relation_flag=RELATION from APP_FLOW_SET where APP_TYPE_CODE=@app_type_code and FLOW_NUM=@flow_num and STEP_NO=@step_no
if(@relation_flag<>'O')
begin
declare cur_get_cond cursor for
select CONDITION,PERSON from APP_FLOW_DIV_CON where TACHE_CODE=@tache_code and ((APP_TYPE_CODE='000' and FLOW_NUM=0 and STEP_NO=0) or (APP_TYPE_CODE=@app_type_code and FLOW_NUM=@flow_num and STEP_NO=@step_no)) order by APP_TYPE_CODE,CON_NO
end
if(@relation_flag='O')
begin
declare cur_get_cond cursor for
select CONDITION,PERSON from APP_FLOW_DIV_CON where TACHE_CODE=@tache_code and APP_TYPE_CODE=@app_type_code and FLOW_NUM=@flow_num and STEP_NO=@step_no
end
open cur_get_cond
fetch cur_get_cond into @gowhere_exp,@post_or_name
while (@@sqlstatus=0)
begin
select @place_mark=charindex('APP_BASE_INFO.APP_TYPE_CODE',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=APP_BASE_INFO.APP_TYPE_CODE from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.APP_TYPE_CODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.APP_TYPE_CODE',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.APP_TYPE_CODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.APP_TYPE_CODE',@gowhere_exp)
end
end
select @place_mark=charindex('APP_BASE_INFO.CHARGE_MODE',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=APP_BASE_INFO.CHARGE_MODE from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.CHARGE_MODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.CHARGE_MODE',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.CHARGE_MODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.CHARGE_MODE',@gowhere_exp)
end
end
select @place_mark=charindex('APP_BASE_INFO.VOLT_LEVEL_CODE',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=str(APP_BASE_INFO.VOLT_LEVEL_CODE) from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.VOLT_LEVEL_CODE'),@exp_col_value_str)
select @place_mark=charindex('APP_BASE_INFO.VOLT_LEVEL_CODE',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.VOLT_LEVEL_CODE'),@exp_col_value_str)
select @place_mark=charindex('APP_BASE_INFO.VOLT_LEVEL_CODE',@gowhere_exp)
end
end
select @place_mark=charindex('APP_BASE_INFO.BUSINESS_PLACE_CODE',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=APP_BASE_INFO.BUSINESS_PLACE_CODE from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.BUSINESS_PLACE_CODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.BUSINESS_PLACE_CODE',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.BUSINESS_PLACE_CODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.BUSINESS_PLACE_CODE',@gowhere_exp)
end
end
select @place_mark=charindex('APP_BASE_INFO.ELEC_TYPE_CODE',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=APP_BASE_INFO.ELEC_TYPE_CODE from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.ELEC_TYPE_CODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.ELEC_TYPE_CODE',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.ELEC_TYPE_CODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.ELEC_TYPE_CODE',@gowhere_exp)
end
end
select @place_mark=charindex('APP_BASE_INFO.APP_NEW_ADD_CAP',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=str(APP_BASE_INFO.APP_NEW_ADD_CAP) from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.APP_NEW_ADD_CAP'),@exp_col_value_str)
select @place_mark=charindex('APP_BASE_INFO.APP_NEW_ADD_CAP',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.APP_NEW_ADD_CAP'),@exp_col_value_str)
select @place_mark=charindex('APP_BASE_INFO.APP_NEW_ADD_CAP',@gowhere_exp)
end
end
select @place_mark=charindex('APP_BASE_INFO.IS_DF_BUILD',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=APP_BASE_INFO.IS_DF_BUILD from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.IS_DF_BUILD'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.IS_DF_BUILD',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.IS_DF_BUILD'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.IS_DF_BUILD',@gowhere_exp)
end
end
select @place_mark=charindex('APP_BASE_INFO.POWER_TYPE_CODE',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=APP_BASE_INFO.POWER_TYPE_CODE from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.POWER_TYPE_CODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.POWER_TYPE_CODE',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.POWER_TYPE_CODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.POWER_TYPE_CODE',@gowhere_exp)
end
end
select @place_mark=charindex('APP_BASE_INFO.MS_MODE',@gowhere_exp)
if (@place_mark<>0)
begin
select exp_col_value_str=null
select @exp_col_value_str=APP_BASE_INFO.MS_MODE from APP_BASE_INFO where APP_BASE_INFO.APP_NO=@app_no
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.MS_MODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.MS_MODE',@gowhere_exp)
while (@place_mark<>0)
begin
select @gowhere_exp=stuff(@gowhere_exp,@place_mark,datalength('APP_BASE_INFO.MS_MODE'),'^'+@exp_col_value_str+'^')
select @place_mark=charindex('APP_BASE_INFO.MS_MODE',@gowhere_exp)
end
end
-----------------------------------------------------------以上是前半部分