dbptk-developer icon indicating copy to clipboard operation
dbptk-developer copied to clipboard

siard --> microsoft sql: Error executing query: ALTER TABLE ... ADD FOREIGN KEY

Open ibbenz opened this issue 2 years ago • 4 comments

Description: A siard file is loaded with dbptk into a Microsoft SQL Database. No error message occurs during the transfer, but in the end only 2 out of 8 tables are transferred. Only in the dbvtk.log the user can see, that an error occured during an ALTER TABLE query as a part of the automatic transfer process.

Steps required to reproduce the bug:

  1. Load the siard-file in dbptk
  2. Send to Live DBMS (Choose SQL)
  3. Notice in SQL-Database that only 2 Tables were loaded.

The siard-file: 0_1-3_Northwind_simple_220913.zip

Attach the dbptk-app.log.txt file below. dbvtk.log

ibbenz avatar Sep 19 '22 08:09 ibbenz

The database user has the correct permissions?

hmiguim avatar Sep 20 '22 13:09 hmiguim

Meanwhile I checked the permissions of the user/login "testlogindbptk" This was the login/user which I created for the upload siard-->microsoft sql.

In order to check, if the user has the permission to alter the tables, I did the following:

  1. I log into the Microsoft SQL Server Management Studio as user "testlogindbptk"
  2. I create a table with two columns which are used as primary and foreign key.
  3. I create the primary and foreign key.

I captured the process in the attached video:

https://user-images.githubusercontent.com/58251561/191464214-d2f17c5c-4a7c-4341-a2f5-53084c0101f2.mp4

ibbenz avatar Sep 21 '22 09:09 ibbenz

Hi,

Manage to find the problem:

SQL Error [8111] [S0001]: Cannot define PRIMARY KEY constraint on nullable column in table 'Customers'.

However due to the way DBPTK works it executes the prepared statements in batches making the errors not so obvious.

hmiguim avatar Sep 21 '22 14:09 hmiguim

Thank you. I have changed accordingly key-relevant columns from _true to false. Now the tables are correctly imported from SIARD into SQL.

ibbenz avatar Sep 22 '22 07:09 ibbenz