create index PATCOSDATA.ix_type_visitname on PATCOSDATA.PATCOS_BACKVISIT_TYPE (VISIT_TYPE_NAME);
create index PATCOSDATA.ix_type_visitcode on PATCOSDATA.PATCOS_BACKVISIT_TYPE (VISIT_TYPE_CODE);
--create synonym
create public synonym PATCOS_BACKVISIT_TYPE for PATCOSDATA.PATCOS_BACKVISIT_TYPE;
create public synonym backvisit_code_autoinc for PATCOSDATA.backvisit_code_autoinc;
drop sequence backvisit_code_autoinc;
create sequence backvisit_code_autoinc
minvalue 1
maxvalue 999999
start with 1
increment by 1
nocache;
create or replace trigger insert_backvisit_type_autoinc
before insert on PATCOSDATA.PATCOS_BACKVISIT_TYPE
for each row
begin
select backvisit_code_autoinc.nextval into :new.VISIT_TYPE_CODE from dual;
end insert_backvisit_type_autoinc;