on 2014 Aug 03 5:46 AM
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" (
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
select @count=count() from Z_product_Pachufaqi where Z_product_Pachufaqi.product_code=new_part.product_code;
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
50 | |
9 | |
8 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.