SQL Drop Primary Key

Starting a new topic as the previous one was getting a bit random …

Using v17r6:


Begin SQL
ALTER TABLE ListItems drop primary key ;
End SQL

C_TEXT(errText;errODBC)
C_LONGINT(errCode;errSQLServer)
ARRAY TEXT($atConstraintName;0)
ARRAY TEXT($atTableName;0)
ARRAY TEXT($atContrataintYpe;0)
Begin SQL
SELECT CONSTRAINT_NAME
FROM _USER_CONSTRAINTS
WHERE TABLE_NAME=‘ListItems’ AND CONSTRAINT_TYPE=‘4DR’
INTO :$atConstraintName
End SQL
SQL GET LAST ERROR(errCode;errText;errODBC;errSQLServer)


Upon executing the first SQL, I get the error
Cannot alter primary key definition of table ListItems
The list of foreign key constraints is not empty for table: ListItems of database: CatBasev8b272

After executing the second SQL, the $atConstraintName array is empty, and there are no errors.

Any ideas?

Thanks!

Pat

Some questions…

  • just curious: why are you using SQL for that? What happens if you remove the PK “by hand”?
  • maybe a screenshot of that table could help
  • restricting the query with CONSTRAINT_TYPE=‘4DR’ may hide something