/*  Скрипт добавляет индекс по полю с версией слоя */

/* <TRANS_COMMAND>
CREATE INDEX IDX_LAYERDATA_LAYERVERSION ON LAYERDATA(LAYERVERSION,LAYERREF)'
/
COMMIT WORK
/
*/
-- <TRANS_IGNORE>

DECLARE
  v_exists INTEGER;
BEGIN
  SELECT COUNT(*)
  INTO v_exists
  FROM USER_INDEXES
  WHERE INDEX_NAME = 'IDX_LAYERDATA_LAYERVERSION';
  IF (v_exists = 0) THEN
    EXECUTE IMMEDIATE 'CREATE INDEX IDX_LAYERDATA_LAYERVERSION ON LAYERDATA(LAYERVERSION,LAYERREF)';
    
    EXECUTE IMMEDIATE 'COMMIT WORK';
  END IF;
END;



