Redian新闻
>
如何让SQL 2005 CLR Trigger返回结果给Stored Procedure用?
avatar
如何让SQL 2005 CLR Trigger返回结果给Stored Procedure用?# Database - 数据库
a*8
1
(1) Apply following CLR Trigger when delete record from Table_1
For row to be deleted
Get associated tax from external file system.
(2) Delete_Stored_Procedure (non CLR)
DELETE from Table_1 where Year = 2008
问题是: CLR Trigger如何将Associated tax返回给Delete_Stored_Procedure?
谢谢!
avatar
j*n
2
Is trigger necessary? you can get associated tax for records being deleted
first and then delete.
avatar
a*8
3
Assume a couple of "delete" operation may appear:
- delete from Table_1 where Year = 2008
- delete from Table_1 where Year < 2008
- delete from Table_1 where Name = 'John'
Applying an trigger on delete is a simple & direct way.
avatar
p*l
4
Try to put into another table?
avatar
a*8
5
Yes. It should be ok to put result into another table then read it in stored
procedure. I'm wondering any other ways can help that.
avatar
j*n
6
hehe, 2k5 new feature....
OUTPUT clause
delete from Table_1
OUTPUT DELETED.*
where Year = 2008
avatar
B*g
7
你这个不还是要一个temp table吗?

【在 j*****n 的大作中提到】
: hehe, 2k5 new feature....
: OUTPUT clause
: delete from Table_1
: OUTPUT DELETED.*
: where Year = 2008

avatar
j*n
8
his SP could catch this data set itself, why need temp table?

【在 B*****g 的大作中提到】
: 你这个不还是要一个temp table吗?
avatar
a*8
9
I need get "TAX" information from external file system. How can T-SQL SP get
it? I think we can re-write CLR SP, but it'll involve a lot of changes -
that's I'm trying to avoid.
avatar
B*g
10
delete output can only get the deleted ids, then use this ids to get tax
from external source.

【在 j*****n 的大作中提到】
: his SP could catch this data set itself, why need temp table?
avatar
j*n
11
no idea about CLR SP... can you use xp_commandshell within your T-sql sp? it
might need higher privilege though.

get

【在 a******8 的大作中提到】
: I need get "TAX" information from external file system. How can T-SQL SP get
: it? I think we can re-write CLR SP, but it'll involve a lot of changes -
: that's I'm trying to avoid.

avatar
B*g
12
1. delete output
2. CLR user defined function (input id list)
get tax in function.
return id+tax list

it

【在 j*****n 的大作中提到】
: no idea about CLR SP... can you use xp_commandshell within your T-sql sp? it
: might need higher privilege though.
:
: get

avatar
j*n
13


【在 B*****g 的大作中提到】
: 1. delete output
: 2. CLR user defined function (input id list)
: get tax in function.
: return id+tax list
:
: it

avatar
a*8
14
THX!
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。