Skip to Content
0
Jun 22, 2015 at 02:31 PM

[HDB] Avoid duplicate entries

497 Views

Hi Expert,

I'm quite new in SQL so sorry if my question is not so interresting...

I would avoir duplicate rows into a SAP HANA table, so I started to create a trigger after input on my table and then do a select into the same table to check a duplicate rows then do a rollback.

It seams that I cannot do a select from the current table and It is not allowed to do a rollback.

So my question is how can I do what I want to do.

Here is what I want to do :

create TRIGGER "NEO_6NR5ZT2KPZ3MK165C5CFGBBEF"."demo1"               
      after INSERT On "NEO_6NR5ZT2KPZ3MK165C5CFGBBEF"."T_IOT_697268A983FC91F50620_1"
      for each row  
      BEGIN


      DECLARE SAMPLE_COUNT INT;
  SELECT COUNT(*) INTO SAMPLE_COUNT FROM "NEO_6NR5ZT2KPZ3MK165C5CFGBBEF"."T_IOT_697268A983FC91F50620_1";


  IF :SAMPLE_COUNT = 0 then
  rollback;
  end if;


END;

Regards,