CREATE TABLE LOGINTHOSPTECDIET(
    CDFILIAL      VARCHAR2(4) ,
    URLREQUEST      VARCHAR2(200),
    PARAMREQUEST  VARCHAR2(4000),
    DTHRREQUEST   DATE              DEFAULT SYSDATE,
    JSONRESPONSE  LONG RAW,
    IDSITUACAO      VARCHAR2(2)     DEFAULT 'S'     NOT NULL
        CONSTRAINT CKC_IDSITUACAOLOG CHECK (IDSITUACAO IN ('E', 'S')),
    DESCERRO      VARCHAR2(4000),
    DIRANEXO      VARCHAR2(4000),
    EMAILNOTIF      VARCHAR2(200),
    SITUACAONOTIF VARCHAR2(4000),
    JSONERRO VARCHAR2(4000),
    CDOPERADOR    VARCHAR2(12),
    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_LOGINTHOSPTECDIET CHECK (IDATIVO IN ('S','N'))
)
/

CREATE TABLE PARAMINTHOSPTECDIET (
    NRPARAMINTHOSPTECDIET       NUMBER NOT NULL,
    CDFILIAL   VARCHAR2(4)       NOT NULL,
    URLAPI       VARCHAR2(200)  NOT NULL,
    PARAMAPI   VARCHAR2(4000),
    CHAVEAPI   VARCHAR2(4000) NOT NULL,
    EMAILNOTIF VARCHAR2(200),
    IDURLSTATUS VARCHAR2(1)  DEFAULT 'N' NOT NULL
        CONSTRAINT CKC_IDURLSTATUS CHECK (IDURLSTATUS IN ('N', 'S')),
	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_PARAMINTHSPTECDIET CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE PARAMINTHOSPTECDIET ADD CONSTRAINT PK_PARAMINTHOSPTECDIET PRIMARY KEY (NRPARAMINTHOSPTECDIET)
/