--ABS-157483

CREATE OR REPLACE PROCEDURE REASONCODE_CONSTRAINT IS

  vOldName user_constraints.constraint_name%TYPE;
begin
  select constraint_name
  into   vOldName 
  from   user_constraints 
  where  TABLE_NAME='REASONCODE' 
  AND SEARCH_CONDITION_VC like '%NOSCANDELIVERY IN %';

  if(vOldName <> 'CHK_REASONCODE_NOSCANDELIVERY') 
  then
    execute immediate 'alter table reasoncode rename constraint ' 
      || vOldName || ' to CHK_REASONCODE_NOSCANDELIVERY'; 
   end if;
end REASONCODE_CONSTRAINT;

/
EXECUTE REASONCODE_CONSTRAINT;
DROP PROCEDURE REASONCODE_CONSTRAINT;
