Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Sybase > Trigger not executed as expected

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-22-07, 11:29
per4711 per4711 is offline
Registered User
 
Join Date: Nov 2006
Posts: 2
Trigger not executed as expected

We have discovered some wierd behavior. Please read the the example procedure and example trigger before I explain the problem.

Procedure X does this:
...
open crsr
fetch crsr into @number
while(@@sqlstatus = 0)
begin
insert into tableY(number) values(@number)
....
fetch crsr into @number
end
deallocate cursor crsr
...


Inserttrigger on table tableY:
create trigger trg_test on tableY for insert as
declare
@id numeric(10,0)
begin transaction
select @id = id from inserted
select @number = isnull(max(number), 0) + 1 from tableY
update tableY set number = @number where id = @id
commit


The Problem
For some reason we ended up with several rows in tableY with the identical value in the column number.

Of cource we could avoid this by adding an unique constraint but I would really like to know how this happend. And I also found the same error in another column where an constraint is not an option.

We use "Lock scheme Datarows" on tableY.

During the execution of procedure X we detected the error "The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'tempdb' database.". This error has never been seen before and procedure X has not been modified (and we have not changed the option "ddl in tran").

Does anyone have a clue what this is?

I would appreciate a solution very much since we have spent almost a week to cleen everything up after this error.

Thank you!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On