ALTER TRIGGER "tr_part_in" after insert order 2 on dba.part referencing new as new_part for each row begin declare @count long varchar; select product_code,parent_id,n22,@count from Z_product_Pachufaqi where Z_product_Pachufaqi.product_code=new_part.product_code; --Assignment @count case when (new_part.location_id='CP' and @count='' ) -- Whether thecontent is empty then Raiserror 30002 'Please select the correct category'; -- This operation not permitted else end case; end ERROR: SQLSTATE = 07005 [Sybase][ODBC Driver][SQL Anywhere]Result set not permitted in 'tr_part_in' No changes made to database. INSERT INTO "part" ( |
You select statement is generating a result set and you have not 'stored' it anywhere - i.e. you need to put it into a temporary table (or a variable if the result set is a single row). You need to do this because a result set cannot be propagated outside of the trigger. Put another way: A trigger cannot generate/propagate a result set. From the comment in the code it looks like you are trying to assign @count with a value ... but I do not know which value you want to assign it with. See the documentation on the SELECT statement, and in particular the "INTO clause". Fix the select statement and your problem will be fixed. answered 03 Aug '14, 15:22 Mark Culp |
case when (new_part.location_id='CP' and @count=0 ) -- Whether thecontent is empty then Raiserror 30002 'Please select the correct category'; -- This operation not permitted else end case; end New_part.product_code exists in the new_part.product_code,if there do not exist then not allowed to write to the database answered 04 Aug '14, 02:04 mfkpie8 |