
/*------ ATD 445943 ------*/
DECLARE v_count NUMBER:=0;

BEGIN
	SELECT Count(1) INTO v_count FROM USER_TABLES WHERE UPPER(table_name) = 'RELACIONACANCELAMENTOTRANSFERENCIA';
	IF v_count = 0 THEN

		EXECUTE IMMEDIATE 'CREATE TABLE RELACIONACANCELAMENTOTRANSFERENCIA(
		ID NUMBER(10) NOT NULL,
		NUMORDCANCELAMENTO NUMBER(10) NOT NULL,
		NUMORDTRANSFERENCIADEVOLVIDA NUMBER(10) NOT NULL,
		NUMORDTRANSFERENCIA NUMBER(10) NOT NULL)';

		EXECUTE IMMEDIATE 'ALTER TABLE RELACIONACANCELAMENTOTRANSFERENCIA ADD CONSTRAINT PK_RelacionaCancelamentoTransferencia PRIMARY KEY (ID)';

		BEFORE INSERT ON RELACIONACANCELAMENTOTRANSFERENCIA FOR EACH ROW

		WHEN (new.ID IS NULL)

		BEGIN
			SELECT RELACIONACANCELAMENTOTRANSFERENCIA.NEXTVAL INTO :new.ID FROM dual;
		END;

	END IF;

END;
