java.sql.SQLException: Parameter Type Conflict
<p>Using oracle 12c. Here is my procedure for save or update which should return id in case of saving new record:</p>

<pre><code>  procedure save_dsc (p_id  in out integer,
                 p_caption_name   in     varchar2,
                 p_dat_id         in     integer,
                 p_dsc_id         in out   integer)
is
begin
   if p_dsc_id is null
        then
            select c.id
              into p_dsc_id
              from pod_data_set_category c
             where c.dat_id = p_dat_id and dsc_id is null;
   end if;

    if p_id is null
    then
          insert into pod_data_set_category (id,
                                                 caption_name,
                                                 dat_id,
                                                 dsc_id)
        values (pod_dsc_seq.nextval,
                p_caption_name,
                p_dat_id,
                p_dsc_id) 
  returning id
          into p_id;
    else
        update pod_data_set_category
           set caption_name = p_caption_name,
               dsc_id = p_dsc_id
         where id = p_id;
    end if;
end;    
</code></pre>

<p>and here is java code:</p>

<pre><code>  try (CallableStatement stmt = connection.prepareCall("{call save_dsc(?,?,?,?)}")) {
        stmt.registerOutParameter(1, Types.INTEGER);

        if (entryCategoryBean.getId() != null) {
            log.debug("Update");
            stmt.setInt(1, entryCategoryBean.getId());
            stmt.setNull(3, Types.NULL);
        } else {
            log.debug("Create");
            stmt.setNull(1, Types.INTEGER);
            stmt.setInt(3, entryCategoryBean.getDatasetId());
        }
        stmt.setString(2, entryCategoryBean.getName());
        if (entryCategoryBean.getParentId()!= null) {
            stmt.setInt(4, entryCategoryBean.getParentId());
        }
        else {
            stmt.setNull(4,Types.NULL);
        }
        stmt.registerOutParameter(4, Types.INTEGER);
        stmt.execute();

        if (entryCategoryBean.getId() == null) {
            entryCategoryBean.setId(stmt.getInt(1));
        }
    }
</code></pre>

<p>Either I do save or update i get java.sql.SQLException: Parameter Type Conflict.
How to fix that?</p>

<p><strong>FIXED this way:</strong></p>

<pre><code>procedure save_dsc (p_id  in out integer,
                 p_caption_name   in     varchar2,
                 p_dat_id         in     integer,
                 p_dsc_id         in    integer)
is
  v_dsc_id integer :=p_dsc_id;
begin
   if (p_dsc_id is null)
        then
            select c.id
              into v_dsc_id
              from pod_data_set_category c
             where c.dat_id = p_dat_id and dsc_id is null;

   end if;

    if p_id is null
    then
          insert into pod_data_set_category (id,
                                                 caption_name,
                                                 dat_id,
                                                 dsc_id)
        values (pod_dsc_seq.nextval,
                p_caption_name,
                p_dat_id,
                v_dsc_id) 
  returning id
          into p_id;
    else
        update pod_data_set_category
           set caption_name = p_caption_name,
               dsc_id = v_dsc_id
         where id = p_id;
    end if;
end;    
</code></pre>