Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 First Trans

Author  Topic 

ann
Posting Yak Master

220 Posts

Posted - 2006-07-07 : 19:14:23
Hi- I am writing my first tran and am having an issue with my where clause:
CREATE PROCEDURE UpdateSatisfied
@NoteID int
,@CreateDate datetime
,@NoteAuthor VARCHAR(20)
,@CaseNote CHAR(12)
,@fraudCaseID int

AS

BEGIN TRAN
UPDATE SatisfyNotes
SET
NoteAuthor = @NoteAuthor
,CreateDate = @CreateDate
,CaseNote = @CaseNote

IF (@@ERROR <> 0) GOTO ERR_HANDLER

INSERT INTO CaseNotes(NoteStatus)
VALUES ('Satisfied')
WHERE CaseNotes.NoteID = @NoteID

IF (@@ERROR <> 0) GOTO ERR_HANDLER

COMMIT TRAN

RETURN 0

ERR_HANDLER:

ROLLBACK TRAN
RETURN 1

can someone help? Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-07-07 : 19:26:42
The first UPDATE statement is missing a WHERE clause. If a WHERE is not present, you are updating all rows in the table, not just one row.

The first INSERT statement should be a UPDATE statement too.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

ann
Posting Yak Master

220 Posts

Posted - 2006-07-07 : 21:10:00
oops! thanks!
Go to Top of Page
   

- Advertisement -