CREATE TABLE BOLQRCODE(
    CDFILIAL      	  VARCHAR2(04) NOT NULL,
    NRLANBOLREC   	  VARCHAR2(10) NOT NULL,
    DSQRCODEB64   	  CLOB,
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
	   CONSTRAINT CKC_IDATIVO_BOLQRCODE CHECK (IDATIVO IN ('S','N')),
	   CONSTRAINT PK_BOLQRCODE PRIMARY KEY (CDFILIAL, NRLANBOLREC)
)
/
ALTER TABLE BOLQRCODE ADD CONSTRAINT FKFIN00414BOLETRECEBER FOREIGN KEY  (CDFILIAL, NRLANBOLREC) 
   REFERENCES BOLETRECEBER (CDFILIAL, NRLANBOLREC) ON DELETE CASCADE
/

CREATE INDEX FIN00414_FK ON BOLQRCODE (CDFILIAL ASC, NRLANBOLREC ASC)
/