对存储过程有疑问:
如何从声明为输出变量的存储过程中检索变量的值。
运行程序为:
EXEC pn_investment_type_eqt {args}
这是存储过程:
create proc pn_investment_type_eqt
(
@product_type varchar(10),
@country varchar(10),
@fi_treatment varchar(1)= '',
@investment_type varchar(10) output,
@investment_description varchar(50) output
)
as
set nocount on
if @country <> 'US'
select @country = 'FOREIGN'
if ( @fi_treatment not in ('Y','N') )
select @fi_treatment = 'N'
if not exists(select 1 from d_investment_type_eqt
where product_type = @product_type and isNull(country,'') = isNull(@country,'') and fi_treatment = @fi_treatment and row_status='A' )
begin
select @country = 'ANY'
end
if exists ( select 1 from d_investment_type_eqt
where product_type = @product_type and isNull(country,'') = isNull(@country,'') and fi_treatment = @fi_treatment and row_status='A' )
begin
select @investment_type= investment_type , @investment_description = description
from d_investment_type_eqt
where product_type = @product_type and isNull(country,'') = isNull(@country,'') and fi_treatment = @fi_treatment and row_status='A'
end
else
return (-1)
我需要获得@investment_type&amp;的值@investment_description
我无法更改程序。
我正在使用Spring 2.0的jdbcTemplate的自定义实现(sql,mapper,args)
数据库是Sybase
我如何从此存储过程中获得结果?
答案 0 :(得分:2)
看一下这篇sybase-in-and-out-parameters帖子,它可能对你有所帮助。
答案 1 :(得分:0)
我决定使用下一个设计:
declare @investment_type_value varchar(10)
declare @investment_description_value varchar(50)
SET @investment_type_value = '3041'
EXEC global..pn_investment_type_eqt 'CVPFDST', 'US', 'N', @investment_type = @investment_type_value output , @investment_description = @investment_description_value OUTPUT
select investment_type = @investment_type_value, investment_description = @investment_description_value
GO
它使我有可能检索变量值。