Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.

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" (

asked 03 Aug '14, 04:46

mfkpie8's gravatar image

mfkpie8
288667176
accept rate: 12%

edited 03 Aug '14, 15:15

Mark%20Culp's gravatar image

Mark Culp
25.0k10142298


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.

permanent link

answered 03 Aug '14, 15:22

Mark%20Culp's gravatar image

Mark Culp
25.0k10142298
accept rate: 41%

Comment Text Removed
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

permanent link

answered 04 Aug '14, 02:04

mfkpie8's gravatar image

mfkpie8
288667176
accept rate: 12%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×79

question asked: 03 Aug '14, 04:46

question was seen: 2,538 times

last updated: 04 Aug '14, 02:04