CREATE TABLE PARAMIMPPROD 
(
    CDNIVPROD            	VARCHAR2(2)     NOT NULL,
    CDVRINICNIVPROD      	VARCHAR2(4)     NULL,
    CDSEQNIVPROD         	VARCHAR2(4)     NULL,
    NRORG                	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO         	    VARCHAR2(1)  	DEFAULT 'S',
		CONSTRAINT CKC_IDATIVO_PARAMIMPPROD CHECK (IDATIVO IN ('N','S')),
    DTINCLUSAO         	 	DATE,
    DTULTATU        	    DATE,
    NRORGINCLUSAO   	    NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
    CDOPERINCLUSAO 	    	VARCHAR2(12)  	NULL,
    NRORGULTATU     	    NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
    CDOPERULTATU    	    VARCHAR2(12)  	NULL,
    CONSTRAINT PK_PARAMIMPPROD PRIMARY KEY (CDNIVPROD)
)
/

INSERT INTO PARAMIMPPROD
   (CDNIVPROD)
(SELECT TO_CHAR(ROWNUM)
  FROM (SELECT (LENGTH(REGEXP_SUBSTR(CDPICTPROD,'[^.]+', 1, LEVEL))) AS TAMMASCARA FROM PARAMGERAL
              CONNECT BY REGEXP_SUBSTR(CDPICTPROD, '[^.]+', 1, LEVEL) IS NOT NULL))
/

COMMIT
/ 