# Error saving temp patient list

**URL:** <https://discourse.project-emerse.org/t/error-saving-temp-patient-list/58>\
**Category:** Uncategorized\
**Created:** [October 16, 2020, 4:07pm UTC](https://discourse.project-emerse.org/t/error-saving-temp-patient-list/58 "2020-10-16T16:07:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin.hostelley](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.project-emerse.org/kevin.hostelley/32/21_2.png) [@kevin.hostelley](https://discourse.project-emerse.org/u/kevin.hostelley)\
**Post date:** [October 16, 2020, 4:07pm UTC](https://discourse.project-emerse.org/t/error-saving-temp-patient-list/58/1 "2020-10-16T16:07:15Z")

</div>

When we try to save patients to a temporary list we receive the following error:

```
ERROR: [2020-10-16T12:02:20,025] edu.umich.med.emerse.rest.AllPatientSearchController.log()83 StatementCallback; SQL [insert into patient_list_entry (id, patient_id, patient_list_id, marked) select entry_seq_id, patient.id,16059, 0 from pt_list_import imp inner join patient on imp.mrn=patient.external_id where imp.existing_flag='N']; ORA-00001: unique constraint (EMERSE.PK26) violated
; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (EMERSE.PK26) violated

```

I tried emptying all the patient\_list\_\* and pt\_list\_\* tables. After that, the first save works but then subsequent ones fail with the above error.

Here’s what I did to empty the lists:

```
TRUNCATE TABLE PT_LIST_IMPORT
TRUNCATE TABLE PATIENT_LIST_SNAPSHOT 
TRUNCATE TABLE PATIENT_LIST_LAST_USED 
TRUNCATE TABLE PATIENT_LIST_HISTORY 
TRUNCATE TABLE PATIENT_LIST_ENTRY_COMMENT 
DELETE FROM PATIENT_LIST_ENTRY 
COMMIT
UPDATE LOGIN_ACCOUNT SET CURRENT_PT_LIST_ID=NULL
COMMIT
DELETE FROM PATIENT_LIST
COMMIT

```

It also works the first time after restarting tomcat, then fails after that. Any Ideas?

---

<div class="post-metadata">

**Author:** ![mcclaink](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.project-emerse.org/mcclaink/32/8_2.png) [@mcclaink](https://discourse.project-emerse.org/u/mcclaink)\
**Post date:** [October 22, 2020, 1:56pm UTC](https://discourse.project-emerse.org/t/error-saving-temp-patient-list/58/2 "2020-10-22T13:56:03Z")

</div>

Hi! Sorry I didn’t get back to you quickly. I’m actually kinda stumped by this issue… Did you figure it out? I suspect that the increment size on the `PATIENT_LIST_ENTRY_SEQ` is wrong. It should be 50, but if it were 1, then that would probably lead to this issue. But, I’m guessing you didn’t make any changes to that.

You shouldn’t need to truncate `PT_LIST_IMPORT` since it’s a global temporary table, so each connection to the DB sees in a sense has “different” table, and when the connection is closed, that “table” is deleted. It’s only used to push the MRNs into the database but also do some validation on them in an easy way.

---

<div class="post-metadata">

**Author:** ![kevin.hostelley](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.project-emerse.org/kevin.hostelley/32/21_2.png) [@kevin.hostelley](https://discourse.project-emerse.org/u/kevin.hostelley)\
**Post date:** [October 22, 2020, 2:14pm UTC](https://discourse.project-emerse.org/t/error-saving-temp-patient-list/58/3 "2020-10-22T14:14:58Z")

</div>

I did figure it out. I meant to come back here and post a follow up but I forgot.

The problem was mine. I needed to replicate our Oracle DB on another server but I didn’t have ssh access to that server. I decided to use liquibase to generate a snapshot of the the db and data. Evidently liquibase doesn’t handle temp tables correctly and created the PT\_LIST\_IMPORT table as a regular table. Once I fixed that everything started to work again.

Thanks for responding though!

Kevin
