Home > database >  The trigger to write for help
The trigger to write for help

Time:10-04

Trigger writing appeals'
Write SQL statements in existing software: insert into AttLog (eid, InputTime, clientid) values (* * * *)

Trigger a: functionality:
4 client_interface_name client_version==odbc
In jym field write "ODBC characters
"

The trigger two: realize functions:
4 client_interface_name client_version==odbc
When the rollback undo the write,

Thank you for the

CodePudding user response:

Where is the jym field?

CodePudding user response:

Jym
Field list is ready

CodePudding user response:

The
reference 1/f, one tree forest _ response:
jym fields in where?


The ready-made fields in the table

CodePudding user response:

update:

Trigger writing appeals'
Write SQL statements in existing software: insert into AttLog (eid, InputTime, clientid) values (* * * *)

Trigger a: functionality:
4 client_interface_name client_version==odbc
In jym field write "ODBC characters
"

The trigger two: realize functions:
4 client_interface_name client_version==odbc
When the rollback undo the write,
If the software in the write SQL statements: insert into AttLog (eid, InputTime, clientid, jym ) values (* * * *)
If in writing SQL statements joined the jym fields content, then no rollback

Thank you for the

CodePudding user response:

 
- you try, I didn't do the test,
CREATE the TRIGGER Trig_Test ON table
AFTER INSERT
AS
The Begin
DECLARE @ ID VARCHAR (20)
DECLARE @ JYM VARCHAR (20)
SELECT @ ID=eid FROM inserted
SELECT @ JYM=JYM FROM table where eid=@ id
IF the EXISTS (SELECT * FROM inserted WHERE ISNULL (@ JYM, ' ')=' ')
The BEGIN
The UPDATE table set JYM='ODBC WHERE eid=@ ID;
RETURN
END
IF the EXISTS (SELECT * FROM inserted WHERE @ JYM='ODBC')
The BEGIN
RETURN
END
END
GO

CodePudding user response:

refer to fifth floor one tree forest _ response:
 
- you try, I didn't do the test,
CREATE the TRIGGER Trig_Test ON table
AFTER INSERT
AS
The Begin
DECLARE @ ID VARCHAR (20)
DECLARE @ JYM VARCHAR (20)
SELECT @ ID=eid FROM inserted
SELECT @ JYM=JYM FROM table where eid=@ id
IF the EXISTS (SELECT * FROM inserted WHERE ISNULL (@ JYM, ' ')=' ')
The BEGIN
The UPDATE table set JYM='ODBC WHERE eid=@ ID;
RETURN
END
IF the EXISTS (SELECT * FROM inserted WHERE @ JYM='ODBC')
The BEGIN
RETURN
END
END
GO

This is the data table structure:


I tested, can pass, but there is no use in figure 2 two variables



CodePudding user response:

Select the host_name client_interface_name, client_version nt_user_name, program_name from Sys. Dm_exec_Sessions where Session_id=@ @ spid

CodePudding user response:

refer to fifth floor one tree forest _ response:
 
- you try, I didn't do the test,
CREATE the TRIGGER Trig_Test ON table
AFTER INSERT
AS
The Begin
DECLARE @ ID VARCHAR (20)
DECLARE @ JYM VARCHAR (20)
SELECT @ ID=eid FROM inserted
SELECT @ JYM=JYM FROM table where eid=@ id
IF the EXISTS (SELECT * FROM inserted WHERE ISNULL (@ JYM, ' ')=' ')
The BEGIN
The UPDATE table set JYM='ODBC WHERE eid=@ ID;
RETURN
END
IF the EXISTS (SELECT * FROM inserted WHERE @ JYM='ODBC')
The BEGIN
RETURN
END
END
GO





I met don't understand myself to change, contact you again, thank you very much!

CodePudding user response:

refer to fifth floor one tree forest _ response:
 
- you try, I didn't do the test,
CREATE the TRIGGER Trig_Test ON table
AFTER INSERT
AS
The Begin
DECLARE @ ID VARCHAR (20)
DECLARE @ JYM VARCHAR (20)
SELECT @ ID=eid FROM inserted
SELECT @ JYM=JYM FROM table where eid=@ id
IF the EXISTS (SELECT * FROM inserted WHERE ISNULL (@ JYM, ' ')=' ')
The BEGIN
The UPDATE table set JYM='ODBC WHERE eid=@ ID;
RETURN
END
IF the EXISTS (SELECT * FROM inserted WHERE @ JYM='ODBC')
The BEGIN
RETURN
END
END
GO






CREATE the TRIGGER Trig_tbattlog ON tbattlog
AFTER INSERT
AS
The Begin
DECLARE @ InID decimal (18, 0)
SELECT @ InID=id FROM inserted
IF the EXISTS (SELECT clientid FROM inserted WHERE clientid=1 and len (ltrim (jym))=0)
The BEGIN
The UPDATE tbAttLog set JYM=left (cast ((select client_version from Sys. Dm_exec_Sessions where Session_id=@ @ spid) as VARCHAR) + (select host_name from Sys. Dm_exec_Sessions where Session_id=@ @ spid) + (select client_net_address from Sys. Dm_exec_connections where Session_id=@ @ spid) + (select client_interface_name from Sys. Dm_exec_Sessions where Session_id=@ @ spid), 32) where id=@ InID;
RETURN
END
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related