OK this works in one way. However, if you have a primary key named something 
else it will fail
use the following code to return primary key column number

C_LONGINT($0;$1;$TableNumber_L)
$TableNumber_L:=$1
$Primary_key_field_id_L:=-9
C_TEXT($ConstraintID_txt)

C_LONGINT($Primary_key_field_id_L)
Begin SQL

SELECT CONSTRAINT_ID
FROM _USER_CONSTRAINTS
WHERE TABLE_ID = :$TableNumber_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

$0:=$Primary_key_field_id_L


Hope this helps

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 Oct 25, 2017, at 2:55 AM, Magnus Torell via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
>               If ($fieldname=$pk_fieldname_t)  //Check if there already 
> exists a field
> with syntax "pk_xxxx"
>                               $b_RunSQL:=False
>                       End if 
>                       

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to