You can identify primary key with the following code
$TableLoop_l is table number
Begin SQL

SELECT CONSTRAINT_ID
FROM _USER_CONSTRAINTS
WHERE TABLE_ID = :$TableLoop_l AND CONSTRAINT_TYPE = 'P'
INTO :$ConstraintID_txt;

SELECT COLUMN_ID
FROM _USER_CONS_COLUMNS
WHERE CONSTRAINT_ID = :$ConstraintID_txt
INTO :$Primary_key_field_id_L;
End SQL
Hope this helps someone else

Regards

Chuck
------------------------------------------------------------------------------------------------
 Chuck Miller Voice: (617) 739-0306
 Informed Solutions, Inc. Fax: (617) 232-1064       
 mailto:cjmiller<AT SIGN>informed-solutions.com 
 Brookline, MA 02446 USA Registered 4D Developer                
       Providers of 4D and Sybase connectivity
          http://www.informed-solutions.com  
------------------------------------------------------------------------------------------------
This message and any attached documents contain information which may be 
confidential, subject to privilege or exempt from disclosure under applicable 
law.  These materials are intended only for the use of the intended recipient. 
If you are not the intended recipient of this transmission, you are hereby 
notified that any distribution, disclosure, printing, copying, storage, 
modification or the taking of any action in reliance upon this transmission is 
strictly prohibited.  Delivery of this message to any person other than the 
intended recipient shall not compromise or waive such confidentiality, 
privilege or exemption from disclosure as to this communication. 

> On Aug 6, 2018, at 10:11 AM, Chip Scheide via 4D_Tech <[email protected]> 
> wrote:
> 
> Arnaud,
> Thanks
> 
> I did this:
> on error call - just make the error go away
> for every table
>  for every field
>    is this my "primary key' field?
>     sql command as text to set primary key on the field
>     execute immediate(above sql command)
>       (trying to set a primary key, as primary key generates an error 
> which is suppressed by the above on error call)
> 
> 
> it works to do what I needed, it is fast, and it is done  :)
> 
> Chip
> 
> On Sun, 5 Aug 2018 12:28:39 +0200, Arnaud de Montard via 4D_Tech wrote:
>> 
>>> Le 3 août 2018 à 18:12, Chip Scheide via 4D_Tech 
>>> <[email protected]> a écrit :
>>> 
>>> Thanks,
>>> I do not really use the online docs....
>>> but it is nice to know
>> 
>> SQL script example. 
>> 
>> ++++++++++
>> /* tables and primary keys */
>> 
>> CREATE TABLE Agence
>> (
>> PK INT32 NOT NULL UNIQUE AUTO_INCREMENT,
>> raisonSociale VARCHAR(80),
>> complementAdresse VARCHAR(80),
>> email VARCHAR(80),
>> comments TEXT,
>> PRIMARY KEY (PK)
>> );
>> 
>> CREATE TABLE ContactAgence
>> (
>> PK INT32 NOT NULL UNIQUE AUTO_INCREMENT,
>> nom VARCHAR(80),
>> prenom VARCHAR(80),
>> fonction VARCHAR(80),
>> email VARCHAR(80),
>> FK_agence INT32,
>> comments TEXT,
>> PRIMARY KEY (PK)
>> );
>> 
>> /* indexes */
>> 
>> CREATE INDEX idx1 ON Agence (PK);
>> 
>> CREATE INDEX idx2 ON ContactAgence (PK);
>> 
>> /* relation */
>> 
>> ALTER TABLE ContactAgence ADD CONSTRAINT rel1 FOREIGN KEY (FK_agence) 
>> REFERENCES Agence (PK);
>> ++++++++++
>> 
>> Note: I never create such relations… 
>> 
>> -- 
>> Arnaud de Montard 
>> 
>> 
>> 
>> 
>> **********************************************************************
>> 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]
>> **********************************************************************
> ---------------
> 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