Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about adding/updating records in my trigger

Status
Not open for further replies.

stevo3

Programmer
Jan 7, 2006
2
BE
Hello,

i got a question about:

i got a tableworkitem; with folowing fields:

fields
id, contact_id, comments, portimaid, title, ,officeid,...
example data
1 , 22 , blabla , 2222 , Ticket:Open;2222;bl,1234,.....

trigger on my table
CREATE TRIGGER [testeke] ON [dbo].[workitem]
FOR INSERT, UPDATE
AS

UPDATE workitem
SET portimaid = SUBSTRING(title, 36, 6)
===========>the portimaid is a part of the title formed with the
function substring


what i want:

First thing------------------------------
i want that is possible to update an existing record,
for example the folowwing record for my table workitem:
contact_id, comments, portimaid, title, ,officeid,...
22 , lalalala , 2222 , Ticket:Update;2222;bl,1234,.....

like you can see the portimaid is the same (2222) AND in the title he needs to detect Update
So he needs to update the existing record (with the unique portimaid(2222))
and just add the commments (wich is lalalala) on the existing comment (blablabla), the rest of the record he need to ignore

Second thing---------------------------------------
IF not all this above conditions he just need to add a new record in my workitem database


My question is this a realistic thought or can i solve this otherwise?
Anybody has ideas?

Many Thanks
Steve

 
solve it otherwise -- instead of the trigger, use a computed column

for more information, please post in the SQL Server forum (forum183)

r937.com | rudy.ca
 
Thanks for the answer
r937

But i can't use a computed column because i'm working with Altiris (Helpdesk solution), i'm trying to customize the helpdesk solution and the problem is this solution doesn't accept computed columns :( if he detects a computed column he just ignores it in the output screen :(

so i got no choice i need to do it with a trigger or stored procedure :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top