Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rows_delete fails due to key constraints: Can’t Modify Database Table #1492

Open
tuge98 opened this issue Apr 15, 2024 · 0 comments
Open

Comments

@tuge98
Copy link

tuge98 commented Apr 15, 2024

When attempting to delete observations from the source database using the rows_delete function, we encounter an issue related to key constraints. Specifically, the process fails due to these constraints. However, running a native SQL query for the same task works as expected.

rows_delete(dm_tbl, tbl, copy = copy, in_place = TRUE, by = by, unmatched = "ignore", returning = !!key)
gives the error:  
Error in rows_delete(dm_tbl, tbl, copy = copy, in_place = TRUE, unmatched = "ignore",  : 
Can't modify database table "batch".
Caused by error:
! nanodbc/nanodbc.cpp:2809: 00000: The DELETE statement conflicted with the REFERENCE constraint "FK__data_upload__26F97175".

However native SQL clause will work just fine:

dbExecute(dm_get_con(dm), glue("DELETE FROM batch WHERE batch_id IN ({paste0(batch_id, collapse = ',')})"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant