I have a line of code that works for SqlServer, and wondering if this would work for Oracle. Here is my query:
INSERT INTO event_master (event_id, user_id, type, detail, status, update_timestamp)
VALUES (event_master_id_seq.nextval, :user_id, :type, :detail, :status, :update_timestamp)
and here is my code:
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("user_id", event.getActionAccount().getUser().getId());
parameters.addValue("type", event.getType());
parameters.addValue("detail", event.getDetail());
parameters.addValue("status", event.getStatus());
parameters.addValue("update_timestamp", new java.sql.Timestamp(Instant.now().toEpochMilli()));
long eventId = jdbcTemplate.queryForObject(insertEventMaster, parameters, Long.class);
return eventId;
event_id
is primary key and when this code runs and insert into database, I want this generated event_id. I found other ways around it, but I want to see if this would work. I have an environment where I can't test this locally right now..