Purpose
Assigns local storage that can be used by the remote data server. You can issue this statement from the MapBasic window in MapInfo Pro.
Syntax
Server StatementNumber Bind Column n To Variable, StatusVariable
StatementNumber is an integer value that identifies information about a SQL statement.
n is a column number in the result set to bind.
Variable is a MapBasic variable to contain a column value following a fetch.
StatusVariable is an integer code indicating the status of the value as either null, truncated, or a positive integer value.
Description
The Server Bind Column statement sets up an application variable as storage for the result data of a column specified in a remote Select statement. When the subsequent Server Fetch statement retrieves a row of data from the server, the value for the column is stored in the variable specified by the Server Bind Column statement. The status of the column result is stored in the status variable.
StatusVariable value | ID | Condition |
---|---|---|
SRV_NULL_DATA | -1 | Returned when the column has no data for that row. |
SRV_TRUNCATED_DATA | -2 | Returned when there is more data in the column than can be stored in the MapBasic variable. |
Positive integer value | Number of bytes returned by the server. |
Example
The following is an application to "print" address labels. It assumes that a relational table ADDR exists with 6 columns.
Dim hdbc, hstmt As Integer
Dim first_name, last_name, street, city, state, zip As String
Dim fn_stat, ln_stat, str_stat, ct_stat, st_stat, zip_stat As Integer
hdbc = Server_Connect("ODBC", "DLG=1")
hstmt = Server_Execute( hdbc, "select * from ADDR")
Server hstmt Bind Column 1 To first_name,fn_stat
Server hstmt Bind Column 2 To last_name, ln_stat
Server hstmt Bind Column 3 To street, str_stat
Server hstmt Bind Column 4 To city, ct_stat
Server hstmt Bind Column 5 To state, st_stat
Server hstmt Bind Column 6 To zip, zip_stat
Server hstmt Fetch NEXT
While Not Server_Eot(hstmt)
Print first_name + " " + last_name
Print street
Print city + ", " + state + " " + zip
Server hstmt Fetch NEXT
Wend
Server hstmt Close
Server hdbc Disconnect
See Also:
Server_ColumnInfo() function