我想使用“触发器”根据职业提供信息

时间:2019-04-18 04:59:35

标签: sql sql-server

'触发器'我想根据专业使用情况提供信息。 例如;当我进入工程师时,我添加了“工程师”。这是他的名字和姓氏。作为。

ALTER TRIGGER tigger_example
ON information
AFTER INSERT
AS
IF EXISTS(SELECT * FROM inserted WHERE Person_Job='Engineer')
BEGIN
    PRINT 'Engineer added to list.'+
    'Person Info:' +
    'Name : ' + person_firstname + -- not work
    'Surname : ' + person_lastname -- not work
END
ELSE IF EXISTS(SELECT * FROM inserted WHERE Person_Job='Architect')
BEGIN
    PRINT 'Architect added to list.'+
    'Person Info:' +
    'Name : ' + person_firstname + -- not work
    'Surname : ' + person_lastname -- not work
END
ELSE
BEGIN
    PRINT 'An undefined contact has been added to the list.'
END

错误:

The name "person_firstname" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

1 个答案:

答案 0 :(得分:0)

您必须使用“从插入中选择...”来读取字段值。 例如:

public void password()      
{           
    if (txtusername.Text=="admin" && txtpass.Text=="admin")
    {
        int saveid=1,printid=1,deleteid=1,updateid=1,searchid=1;
        String ww="myschool";
        String role="admin";

        MainForm Form=new 
        MainForm(printid,saveid,searchid,updateid,deleteid,ww,role);

        Form.ShowDialog();
        this.Hide();
    }