English 中文(简体)
能否从方案上援引“公平”?
原标题:is it possible to invoke SQL trigger programmatically?

我知道在这种情况下,我必须使用存储程序

but still I want to know if it is possible? If NO, Why? If YES, How?

最佳回答

By definition "a trigger" is a procedure that fires when a table is changed. I guess you could make it fire programmatically by doing update/delete/create on a table that has a trigger.

如果你想要一个能够人工执行的程序,那么,正如你指出的那样,你就应当建立一种储存的程序。

If you want a procedure that can be executed as a trigger and manually, why not create a stored procedure and then create a trigger that simply has one line that fires that procedure?

如果你撰写了某些测试/诊断法,并且确实需要援引某些触发法,那么你也许能够使用一些气象预报器(我记得Oracle有这样的东西)。 不能确定 server服务器,而是需要做一些事情才能提取该编码,将其编成存储程序。 如果你这样做,如Alex_ 前面已经提到过,你一定会冲破通常只供触发器使用的假装新行。

问题回答

首先要考虑的是:

update yourtable
set yourcolumn = yourcolumn
-- consider a  where  statement

我认为,这将在没有任何变化的情况下援引触发因素。 因此,可以援引法典。

You cannot call triggers directly. They are fired automatically when you perform an insert/update or delete on a table that has triggers. Therefore, you cannot call a trigger in a stored procedure. Trigger needs to have deleted or inserted record when executes, and I cannot see how it can be passed...





相关问题
How to write this T-SQL WHERE condition?

I ve got two tables: TableA Col1 Col2 TableB Col3 Col4 I want to join them together: SELECT * from TableA join TableB ON (...) Now, in place of ... I need to write an expression ...

Customer and Order Sql Statement

TSQL query to select all records from Customer that has an Order and also select all records from customer that does not have an Order. The table Customer contains a primary key of CustomerID. The ...

Recommended way of querying multiple Versioned tables

Have a win 2003 box with MSSQL 2005 running on it. There is a database which is populated every morning with new/modified SalesOrder made the previous day. The database has several tables: SalesOrder, ...

update duplicate record

I have a table with the following fields Id Name IsPublic i need to write a sql query that updates IsPublic to false where name has a duplicate. Only one of the duplicates should have IsPublic = ...

Define variable to use with IN operator (T-SQL)

I have a Transact-SQL query that uses the IN operator. Something like this: select * from myTable where myColumn in (1,2,3,4) Is there a way to define a variable to hold the entire list "(1,2,3,4)"? ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...

热门标签