title: Integrity constraint violated in Oracle
body: <p>I have a two Oracle tables:</p>
  
  <pre><code>CREATE TABLE MANAGEDSYSTEMS(
    MSYSTEMID INTEGER NOT NULL,
    MSYSTEMGROUPID INTEGER,
    SPECIALNUMBER VARCHAR2(40 ),
    SERIALNUMBER VARCHAR2(30 ),
    MSYSTEMSTATUS VARCHAR2(30 ),
    MSYSTEMNAME VARCHAR2(60 ),
    IPADDRESS VARCHAR2(30 ),
    DATEMSYSTEMADDED TIMESTAMP(6),
    DESCRIPTION CLOB
  )
  /
  
  -- ADD KEYS FOR TABLE MANAGEDSYSTEMS
  
  ALTER TABLE MANAGEDSYSTEMS ADD CONSTRAINT MSKEY PRIMARY KEY (MSYSTEMID)
  /
  
  
  CREATE TABLE AGENTS(
    AGENTID INTEGER NOT NULL,
    MSYSTEMID INTEGER,
    AGENTGROUPID INTEGER,
    AGENTSERIALNUMBER VARCHAR2(60 ),
    AGENTSTATUS VARCHAR2(30 ),
    AGENTOS VARCHAR2(60 ),
    AGENTIPADDRESS VARCHAR2(40 ),
    LASTSYNC TIMESTAMP(6),
    DATEAGENTADDED TIMESTAMP(6),
    CPULOADLIMIT INTEGER,
    RAMLOADLIMIT INTEGER,
    HDDSPACELIMIT INTEGER,
    NETWORKUPLIMIT INTEGER,
    NETWORKDOWNLIMIT INTEGER,
    REPORTUSERLOGINS VARCHAR2(30 ),
    CANEXECCOMMANDS VARCHAR2(30 ),
    SYNCHRONIZATIONTIME VARCHAR2(30 ),
    DATALIMITSPEAKTIMES INTEGER,
    DESCRIPTION CLOB
  )
  /
  
  -- ADD KEYS FOR TABLE AGENTS
  
      ALTER TABLE AGENTS ADD CONSTRAINT AGENTID PRIMARY KEY (AGENTID)
  ALTER TABLE AGENTS ADD CONSTRAINT MSYSTEMID FOREIGN KEY (MSYSTEMID) REFERENCES MANAGEDSYSTEMS (MSYSTEMID)
  </code></pre>
  
  <p>I want to assign 'Agent' into the table 'Managedsystems'. As you can see I have a table foreign key - the user must first create managed system and then to create agent. But I also want to give to give a option to create agents without assigning a managed system. When I tried to change the key of the managed system id into the agents table I get this error:</p>
  
  <pre><code>Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02291: integrity constraint (ADMIN.MSYSTEMID) violated - parent key not found
  </code></pre>
  
  <p>It seems that I cannot assign empty values. How I can fix this problem?</p>
  
  <p>UPDATE:</p>
  
  <p>I use this SQL statement to update the agent table:</p>
  
  <pre><code>String sql = "UPDATE AGENTS "
                               + " SET AGENTID = ?, MSYSTEMID = ?, AGENTGROUPID = ?, AGENTSERIALNUMBER = ?, AGENTSTATUS = ?, AGENTOS = ?, AGENTIPADDRESS = ?, "
                               + " LASTSYNC = to_timestamp(?, " + ts_template + "), DATEAGENTADDED = to_timestamp(?, " + ts_template + "), "
                               + " CPULOADLIMIT = ?, RAMLOADLIMIT = ?, HDDSPACELIMIT = ?, NETWORKUPLIMIT = ?, NETWORKDOWNLIMIT = ?, REPORTUSERLOGINS = ?, "
                               + " CANEXECCOMMANDS = ?, SYNCHRONIZATIONTIME = ?, DATALIMITSPEAKTIMES = ?, "
                               + " DESCRIPTION = ? WHERE AGENTID = ?";
  </code></pre>