unknown
2009-11-19 18:01:34 UTC
I have created a stored procedure that generates code to
create views and then executes that code via the execute
immediate function.
I am trying to create an instead of trigger on a view that
rolls back an update/insert/delete. When I try to do this I
get the error:
Msg 11736, Level 15, State 0:
Server 'deva_gen_ase', Procedure
'dbo.TRG_CER_ATAD_ADDRESS_D', Line 3:
line 1: You cannot specify this command in an 'execute
immediate' context.
Basically this fails:
execute ('create trigger dbo.TRG_CER_ATAD_ADDRESS_D on
dbo.CER_ATAD_ADDRESS_D instead of insert, update, delete as
raiserror 9988888 "Updates through masked views not allowed"
rollback ')
But this works fine:
execute ('create trigger dbo.TRG_CER_ATAD_ADDRESS_D on
dbo.CER_ATAD_ADDRESS_D instead of insert, update, delete as
raiserror 9988888 "Updates through masked views not allowed"
')
And this works fine:
execute ('create procedure dbo.foo as raiserror 9988888
"Updates through masked views not allowed" rollback')
So it appears that ASE does not object to the 'rollback' as
it allows it in a procedure, nor does it object to the
'create trigger'.
But the combination of 'rollback' and 'create trigger' seems
offensive. Is this a bug? Is there a workaround? Is there
a good way to rollback a transaction without using rollback?
I do not want to use 'select syb_quit()' and I would like to
avoid having the trigger call a stored procedure that
performs the rollback.
Adaptive Server Enterprise/15.0.3/EBF 16554
ESD#1/P/RS6000/AIX 5.3/ase1503/2681/64-bit/FBO/Mon Mar 9
01:35:28 2009
Thanks,
awh
create views and then executes that code via the execute
immediate function.
I am trying to create an instead of trigger on a view that
rolls back an update/insert/delete. When I try to do this I
get the error:
Msg 11736, Level 15, State 0:
Server 'deva_gen_ase', Procedure
'dbo.TRG_CER_ATAD_ADDRESS_D', Line 3:
line 1: You cannot specify this command in an 'execute
immediate' context.
Basically this fails:
execute ('create trigger dbo.TRG_CER_ATAD_ADDRESS_D on
dbo.CER_ATAD_ADDRESS_D instead of insert, update, delete as
raiserror 9988888 "Updates through masked views not allowed"
rollback ')
But this works fine:
execute ('create trigger dbo.TRG_CER_ATAD_ADDRESS_D on
dbo.CER_ATAD_ADDRESS_D instead of insert, update, delete as
raiserror 9988888 "Updates through masked views not allowed"
')
And this works fine:
execute ('create procedure dbo.foo as raiserror 9988888
"Updates through masked views not allowed" rollback')
So it appears that ASE does not object to the 'rollback' as
it allows it in a procedure, nor does it object to the
'create trigger'.
But the combination of 'rollback' and 'create trigger' seems
offensive. Is this a bug? Is there a workaround? Is there
a good way to rollback a transaction without using rollback?
I do not want to use 'select syb_quit()' and I would like to
avoid having the trigger call a stored procedure that
performs the rollback.
Adaptive Server Enterprise/15.0.3/EBF 16554
ESD#1/P/RS6000/AIX 5.3/ase1503/2681/64-bit/FBO/Mon Mar 9
01:35:28 2009
Thanks,
awh