You can write the code to see if there is already a primary key and not do the 
alter if there is
It is one 
of the hidden sql tables

Array longint(constraintids_al;0)
Array longint(tablenumbers_al;0)

Begin sql
Select constraints_id, table_id
From _user_constraints 
Where constraint_type =ā€˜P’
Into 
:constraintids_al,
:tablenumbers_al;
End sql
Regards 

Chuck 

Sent from my iPhone

> On Jul 25, 2019, at 3:16 PM, Chip Scheide via 4D_Tech <[email protected]> 
> wrote:
> 
> I am working up a method to set the primary key property on a field.
> I am using SQL to do this, as it seems the only way.
> 
> I have working code, but - I noticed if I try to apply the primary key 
> property a second time I get a runtime error either 43 or 44 with the 
> message : Failed to execute ALTER TABLE command.
> 
> So... naturally I setup an ON ERR CALL method to catch and report the 
> problem. However, the error call routine does NOT get either error 43 
> nor 44, it gets error -1!.
> 
> If I remove the ON ERR CALL and generate the error, I get a 4D runtime 
> error dialog  with error 43 or 44, install ON ERR CALL and get error -1.
> 
> Any insights?
> 
> Thanks
> Chip
> ---------------
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing 
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to