OP Define bind by numbers

4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next

version 1.5


OP Define bind by numbers (bindID; tableID; fieldID; localTableID; localFieldID; variableName) Longint

ParameterTypeDescription
bindIDLongintBind list ID
tableIDLongintNumber of table in the database
fieldIDLongintNumber of the field in the table
localTableIDLongintNumber of the table in the local database
(0 if bind to variable)
localFieldIDLongintNumber of the field in the local table
(0 if bind to variable)
variableNameStringName of the variable or array
("" if bind to field)
Function resultLongintError code result for the function

Description

OP Define bind by numbers adds a bind to the bindID bind list for tableID and fieldID on the server, indicated by passing their numbers.

For example, to bind the [Invoices]Invoice ID, and Invoice ID is the first field in the [Invoices] table, which is the second file on the server database, pass 1 as fieldID and 2 as tableID.

In the same way, if you bind a field from the server to a local field, pass the numbers of the table and field to localTableID and to localFieldID and "" to variableName.

To bind tableID and fieldID to a local object such as a variable or an array, pass its name to variableName and pass 0 to localTableID and localFieldID.

variableName can be an interprocess or process variable or array name. variableName cannot be a local variable or array (i.e., using the dollar sign "$").

Error Codes

If OP Define bind by numbers executes successfully, it returns 0. Otherwise, this function returns one of the following errors:

Error CodeDescription
-108Not enough memory to perform this operation.
10128The 4D Open for 4th Dimension package has not been initialized.
10137The bind list does not exist.
10140The local field does not exist.
10141The local table does not exist.
10142You cannot bind this type of field.
10154This command cannot be executed right now.
10157Duplicated bind entry.

Example

This example lists binds between the [Invoices] table fields and several arrays to be used as scrollable areas on a form. This would be a way to display a list of invoices to the user.

   C_LONGINT ($BindID;$ErrCode;$ConnectID)

   ARRAY DATE (aInvDate;0)
   ARRAY REAL (aInvTotal;0)
   ARRAY STRING (30;aCity;0)
   ARRAY STRING (30;aCustID;0)
   ARRAY STRING (30;aCompany;0)

   C_LONGINT (vTableInvoices;vTableCustomers;$unused1)
   C_LONGINT (vFieldDate;vFieldAmount;vFieldCustID;$unused2)
   C_LONGINT (vFieldCompany;vFieldCity)

      ` Get [Invoices] tableID and [Invoices]Invoice date fieldID
   $errCode:=OP Get one field number (vConnectID;"[Invoices]Invoice date";vTableInvoices;vFieldDate)
      ` Get [Invoices]Invoice amount fieldID   
   $errCode:=OP Get one field number (vConnectID;"[Invoices]Invoice amount";$unused1;vFieldAmount)
      ` Get [Invoices]Customer ID fieldID   
   $errCode:=OP Get one field number (vConnectID;"[Invoices]Customer ID";$unused1;vFieldCustID)
      ` Get [Customers] tableID and [Customers]Company fieldID
   $errCode:=OP Get one field number (vConnectID;"[Customers]Company";vTableCustomers;vFieldCompany)
      ` Get [Customers]City fieldID
   $errCode:=OP Get one field number (vConnectID;"[Customers]Company";$unused1;vFieldCity)

      `…Connect to the server
      `…Perform a query on invoices to create a selection of records

   $ErrCode := OP Create bind ($BindID)
   $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableInvoices;vFieldCustID;0;0;"aCustID")
   $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableInvoices;vFieldCustID;0;0;"aInvDate")
   $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableInvoices;vFieldAmount;0;0;"aInvTotal")
   $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableCustomers;vFieldCity;0;0;"aCity")
   $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;vTableCustomers;vFieldCompany;0;0;"aCompany")
   ` On a known stable structure one could also write
   ` $ErrCode := $ErrCode + OP Define bind by numbers ($BindID;1;2;0;0;"aCompany")
   
   If ($ErrCode=0)
      $ErrCode:=OP Selection to array ($ConnectID;$BindID)
   End if 

   $ErrCode:=OP Delete bind ($BindID)

See Also

OP Create bind, OP Define bind by pointer, OP Delete bind, OP Load record, OP Selection to array.


4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next