Jump to content
php.lv forumi

MS SQL TRIGGER


NBS

Recommended Posts

Sveiki, izstāstīšu ko gribu panākt, jo domāju, ka mans kods ir caur vienu vietu.

Vēlos palaist triggeri, lai tas selektē kodu pēc tam pie UPDATE šo pašu kodu pieskaita kontrolsummai, kas tiek veikta caur funkciju "_sp_fao_code_cksm".

Lūdzu, izpalīdziet.

 

CREATE TRIGGER insert_code
ON dbo.customers 
AFTER INSERT 
AS
DECLARE @customerid int
IF UPDATE (code) 
BEGIN
SELECT @customerid=customID FROM inserted
UPDATE customers SET code = (@customerid + _sp_fao_code_cksm(@customerid))  WHERE customerid = @customerid
END

Link to comment
Share on other sites

Beigās sanāca, ka to, ko es gribēju bija neiespējams iegūt :(

Jo nevar izpildīt triggers INSERT UPDATE un tad atkal INSERT UPDATE, nav tādas iespējas.

Triggerī ir tikai paredzēts uzreiz INSERTS un tad tikai UPDATE vai otrādi, nevar katru mainīgo atsevišķi mest.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...