Xbasic

A5_PassiveLinkTableDefine Function

Syntax

Result as P = a5_PassiveLinkTableDefine(* DataSourceDef [,C tablefilename [,L showProgress [,L allowCancel [,* openConnection [,L flagAddTableToDatabase ]]]]])

Arguments

Result

If DataSourceDefis a dot variable with a definition of the data source for the passive-link table, Resultwill be a dot variable with two properties.

Argument
Description
.HasError

.T. = An error occurred. .F. = No error occurred.

.ErrorText

The text of any error that was encountered.

DataSourceDef

Either "Help" (to get the syntax for the data source definition), or a dot variable that defines the data source. When defining the DataSourceDef, the only required properties are:

ds.ConnectionString= specify the connection string
ds.SQLSelectStatement= specify the SQL SELECT statment, or stored procedure name
tablefilename

The filename of the table to create. If DataSourceDefis "Help" then do not specify Tablename. Otherwise, you must specify this argument.

showProgress

Logical

allowCancel

Logical

openConnection

*

flagAddTableToDatabase

Logical

Description

The A5_PassiveLinkTableDefine() function defines a passive link table for a SQL data source. For syntax help specify "Help" as the first argument.

Example 

a5_passiveLinkTableDefine("help") 
= dim ds as p 
ds.ConnectionString = 'specify the connection string 
ds.SQLSelectStatement = 'specify the SQL SELECT statment, or stored procedure name 
ds.Arguments = 'specify what arguments (if any) are used in the SQL statement. Format is a comma delimited list with :argumentName|type. e.g. :whatCity|C,:whatId|N 
ds.SQLType = 'specify the syntax type: "Portable" or "Native" 
ds.AdvancedOptions.SizeToFit = 'specify if character columns are automatically sized to fit: .T. or .F. 
ds.AdvancedOptions.ConvertTimeToDate = 'specify if Date/Time values should be convert to Date values: .T. or .F. 
ds.AdvancedOptions.DefineFieldOverrides = 'specify if column definition overrides will be supplied: .T. or .F. 
ds.AdvancedOptions.OverrideDefinitions = 'A crlf delimited list of fieldspecs to override. E.g. Customer,C,20,0 ""

In this example, we create a passive link table. Notice that we only specify the two properties for the DataSourceDef. All other properties of the DataSourceDefhave default values.

delete ds
dim ds as P
ds.ConnectionString = "{A5API='Access', A5Syntax='Access', FileName='C:\Northwind\northwind.Mdb', UserName='Admin'}" 
ds.SQLSelectStatement = "select customerid, contactname, city from customers" 
a5_passiveLinkTableDefine(ds,"c:\pl_customers.dbf")

In this example, we create a passive link table that uses arguments. Notice that the ds.Argumentsproperty is defined. All other properties of the DataSourceDefhave default values.

delete ds 
dim ds as P
ds.ConnectionString = "{A5API='Access', A5Syntax='Access', FileName='C:\Northwind\northwind.Mdb', UserName='Admin'}" 
ds.SQLSelectStatement = "select * from customers where city = :whatcity"
ds.Arguments = ":whatCity|C" 
a5_passiveLinkTableDefine(ds, "c:\pl_customers.dbf")

In this example, we create a passive link table on a table in an Excelspreadsheet. Since Exceldoes not return the size of each column, Alpha Anywhere defaults to creating all character columns with a width of 255. This is very inefficient and it slows down the import. Therefore, for Excel, we set the ds.AdvancedOptions.SizeToFitproperty to .T. .

delete ds
dim ds as P
  
ds.ConnectionString = "{A5API='Excel', A5Syntax='Excel', FileName='c:\myexceldata.xls'}"
ds.SQLSelectStatement = "select * from sheet1$"
ds.AdvancedOptions.SizeToFit = .t.
a5_passiveLinkTableDefine(ds,"c:\pl_exceldata.dbf")

In this example we define the field types for certain of the columns in the passive-link table. This overrides the default column sizes for these columns that Alpha Anywhere would otherwise use.

delete ds
dim ds as P
  
ds.ConnectionString = "{A5API='Access', A5Syntax='Access', FileName='C:\Northwind\northwind.Mdb', UserName='Admin'}" 
ds.SQLSelectStatement = "select customerid, contactname, city from customers"
ds.AdvancedOptions.DefineFieldOverrides = .t.
ds.AdvancedOptions.OverrideDefinitions = <<%txt%
customerid,c,10,0
city,c,50,0
%txt%
a5_passiveLinkTableDefine(ds, "c:\pl_customers.dbf")

See Also