从另一个存储过程中调用SYBASE存储过程,而不显示“存储过程”结果

发布于 2025-01-21 17:13:01 字数 687 浏览 0 评论 0原文

我正在从另一个存储过程y中调用Sybase存储的过程X。对类似问题的答案,我创建了一个#TMP_Table来保留存储过程X的结果。

create table #tmp_table(
    col1 int,
    col2 varchar(100),
    ...
) exec sp_stored_procedureX 888, 'Parameter2', ...

select * from #tmp_table

以上成功将存储过程X的结果加载到#TMP_Table中,但它显示了两次存储过程X的结果。我猜第一个来自“ Exec sp_stored_procedurex ...”部分,第二个部分来自我想的“ select * * select *”。我不想显示第一个“ EXEC SP_STORED_PROCEDUREX ...”部分中的结果。如何将数据存储到#TMP_Table而不显示的情况下?

如果需要更多澄清/信息,请让我知道。

谢谢问候,

京都

I am calling a Sybase stored procedure X from another stored procedure Y. Following the answer to a similar question , I create a #tmp_table to hold the results from stored procedure X.

create table #tmp_table(
    col1 int,
    col2 varchar(100),
    ...
) exec sp_stored_procedureX 888, 'Parameter2', ...

select * from #tmp_table

The above successfully loads stored procedure X's results into #tmp_table but it shows the results of stored procedure X twice. I guess the first one is from "exec sp_stored_procedureX ..." part and the second one is from "select * from #tmp_table" which I intended. I don't want to display the results from the first "exec sp_stored_procedureX ..." part. How can I store data to #tmp_table without displaying it?

Please kindly let me know if more clarification/information is needed.

Thanks & Regards,

Kyoto

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深缘浅 2025-01-28 17:13:01

您的语法对于ASE中的普通表不正确。但是对于ASE,有一个特殊的表名称RPC表可以将过程的输出映射到表格式输出。也许这就是您要寻找的...也可以从远程ASE调用。
这是一个样本 -

use omni_rpc 
go 

create table rmtbl 
( 
aint int null, 
bchr char(10) null, 
cchr char(10) null 
) 
go 

insert rmtbl values (11, "b_row1", "c_row1") 
insert rmtbl values (22, "b_row2", "c_row2") 
insert rmtbl values (33, "b_row3", "c_row3") 
insert rmtbl values (44, "b_row4", "c_row4") 
insert rmtbl values (55, "b_row5", "c_row6") 
go 

create proc procImm @Colnames varchar(100), @NameT varchar(20), @nameCol varchar 
(20), @value char(2) 
as 
execute ('select ' + @Colnames + ' from ' + @NameT + ' where ' 
+ @nameCol + ' = ' + @value) 

Here @NameT and @Colnames are command parameters, and @value is a search parameter based on the terms defined at the beginning of the paper. 

In the local server: 

use test 
go 
sp_addobjectdef myrpc_imm, "THIS.omni_rpc..procImm", "rpc" 
go 
(return status = 0) 

create existing table myrpc_imm 
( 
NameT varchar(20), 
nameCol varchar(20), 
value varchar(10) 
) 
external procedure at "THIS.omni_rpc..procImm" 
go 
select * from myrpc_imm 
where NameT = 'rmtbl' and nameCol = 'aint' and value = '33' 
go 
NameT                nameCol              value 
-------------------- -------------------- ---------- 

(0 rows affected) 

dbcc traceon(11225) 
go 
00:00000:00017:2004/04/01 12:18:47.03 server DBCC TRACEON 11225, SPID 17 
DBCC execution completed. If DBCC printed error messages, contact a user with 
System Administrator (SA) role. 

select * from myrpc_imm 
where NameT = 'rmtbl' and nameCol = 'aint' and value = '33' 
go 
NameT                nameCol              value 
-------------------- -------------------- ---------- 
33                   b_row3               c_row3 

(1 row affected) 

your syntax is incorrect for normal table in ASE. But for ASE, there's a special table name RPC table can map the output of procedure to a table format output. Maybe that's what you are looking for...And that also can be called from remote ASE.
Here's a sample --

use omni_rpc 
go 

create table rmtbl 
( 
aint int null, 
bchr char(10) null, 
cchr char(10) null 
) 
go 

insert rmtbl values (11, "b_row1", "c_row1") 
insert rmtbl values (22, "b_row2", "c_row2") 
insert rmtbl values (33, "b_row3", "c_row3") 
insert rmtbl values (44, "b_row4", "c_row4") 
insert rmtbl values (55, "b_row5", "c_row6") 
go 

create proc procImm @Colnames varchar(100), @NameT varchar(20), @nameCol varchar 
(20), @value char(2) 
as 
execute ('select ' + @Colnames + ' from ' + @NameT + ' where ' 
+ @nameCol + ' = ' + @value) 

Here @NameT and @Colnames are command parameters, and @value is a search parameter based on the terms defined at the beginning of the paper. 

In the local server: 

use test 
go 
sp_addobjectdef myrpc_imm, "THIS.omni_rpc..procImm", "rpc" 
go 
(return status = 0) 

create existing table myrpc_imm 
( 
NameT varchar(20), 
nameCol varchar(20), 
value varchar(10) 
) 
external procedure at "THIS.omni_rpc..procImm" 
go 
select * from myrpc_imm 
where NameT = 'rmtbl' and nameCol = 'aint' and value = '33' 
go 
NameT                nameCol              value 
-------------------- -------------------- ---------- 

(0 rows affected) 

dbcc traceon(11225) 
go 
00:00000:00017:2004/04/01 12:18:47.03 server DBCC TRACEON 11225, SPID 17 
DBCC execution completed. If DBCC printed error messages, contact a user with 
System Administrator (SA) role. 

select * from myrpc_imm 
where NameT = 'rmtbl' and nameCol = 'aint' and value = '33' 
go 
NameT                nameCol              value 
-------------------- -------------------- ---------- 
33                   b_row3               c_row3 

(1 row affected) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文