私は現在、Sybase ASE 15.7を使用しており、別のSPの結果を使用するストアドプロシージャを記述しています。私はそれを呼び出すと、元のSPのための変更は必要ないので、一時テーブルに結果を挿入したいと思います。ストアドプロシージャの結果セットを一時テーブルに挿入し、Sybaseで出力パラメータを取得するにはどうすればよいですか?
この記事への参照のうえ:プロキシ・テーブルを使用してHow can I get data from a stored procedure into a temp table?
ヤクブの答えは、試料SPの定義と完璧に動作します:
create procedure mydb.mylogin.sp_extractSomething (
@timestamp datetime) as
select column_a, column_b
from sometable
where timestamp = @timestamp
は、しかし行方不明1最後のピースがあります!どのように出力パラメータと結果セットを取得しますか?私の場合はSPは、以下のように定義されています
create procedure mydb.mylogin.sp_extractSomething
(
@timestamp datetime,
@errcode char(10) output
) as
select @errcode='NOERR'
select column_a, column_b
from sometable
where timestamp = @timestamp
if (@@rowcount = 0)
begin
select @errcode = 'ERR001'
end
私は次のように定義し、プロキシ・テーブルを使用したい:結果セットは@errcode
/_errcode
、成功裏に戻すことができますが
--create proxy table
create existing table myproxy_extractSomething (
column_a int not null,
column_b varchar(20) not null,
_timestamp datetime null,
_errcode char(10) null) external procedure at "loopback.mydb.mylogin.sp_extractSomething"
--calling sp
declare @errcode Char
declare @myTimestamp datetime
set @myTimestamp = getdate()
select *
from myproxy_extractSomething
where _timestamp = @myTimestamp
and _errcode = @errcode
select @errcode
です常にnullです。プロキシ・テーブルで出力パラメータを定義するにはどうすればよいですか?