SQL::ImportStatement Object
Syntax
Arguments
- Target_Table_NameCharacter
The full path and table name of an Alpha Anywhere .DBF table that will receive the data.
- Table_ArgumentCharacter
An argument that provides a full path and table name of an Alpha Anywhere .DBF table.
- Database_DefinitionCharacter
A series of field names and specifications in the format: FieldName, Type, Length, DecimalPlaces. DBFDEFINITION can override column names and precision, but must map positionally to an appropriate type.
- Database_Argument
An argument that provides a series of field names and specifications in the format: FieldName, Type, Length, DecimalPlaces.
- FieldNameCharacter
The name of the target field.
- TypeCharacter
The type of the field. Refer to Create a New Table for valid field types.
- LengthNumeric
The total number of character positions for the field.
- DecimalPlacesNumeric
For numbers only. The number of character positions after the decimal point.
- Source_Table_NameCharacter
The specification for an external (non-Alpha Anywhere) table that will provide the data.
- Select_StatementCharacter
A SQL SELECT statement that retrieves data from an external (non-Alpha Anywhere) table. The syntax parsed for the SELECT statement (as with other statements) is portable SQL. The connection passed into the execute function determines the syntax executed.
Description
The SQL::ImportStatement object parses and executes an Alpha Anywhere Portable SQL import statements of the general form.
The SQL::ImportStatement object appends or replaces records in an Alpha Anywhere .DBF table. The object may optionally use a reference table to define the target table's structure or it may define the target table's field structure in-line.
Syntax Examples
In these three cases the target table is created to match the requirements of the imported data.
import with replace into 'c:\test.dbf' select * from customers where city = :city" import with replace into 'c:\test.dbf' FROM customers" import with replace into :targettable DBFDEFINITION :dbfDefinition FROM customers
In these two cases the target table is created to the specifications included in the statements.
import with replace into :targettable DBFDEFINITION ' CUSTOMER_ID,C,15,0 COMPANYNAME,C,40,0 CONTACTNAME,C,30,0 ' FROM customers import with replace into 'c:\test.dbf' DBFDEFINITION ' CUSTOMER_ID,C,15,0 COMPANYNAME,C,40,0 CONTACTNAME,C,30,0 ' FROM customers
Examples
Example usage
dim c as SQL::connection dim i as SQL::importstatement if c.open("{a5api=access,filename=c:\northwind.mdb,username=admin}") if i.parse(importsyntax) i.Arguments.set("targettable", TargetTableName) i.Arguments.set("dbfdefinition", DBFDefinition) i.Arguments.set("city", "London") EventScript = GetEventScript(TargetTableName) if i.executewithevents(c, EventScript) ? success handling code else ? error handling code end if else ? error handling code end if ? error handling code end if
Using the ::PARSE() method.
dim import as SQL::ImportStatement import.Parse("import with replace into 'c:\test.dbf' select * from customers where city = :city")
Using the ::EXECUTE() method.
dim import as SQL::ImportStatement dim stat as C stat = "import with replace into 'c:\test.dbf' select * from customers where city = :city"" import.Execute( stat ) import.ExecuteWithEvents(c, EventScript)
Using the ::ExecuteWithEvents() method.
dim import as SQL::ImportStatement dim stat as C dim EventScript as C stat = "import with replace into 'c:\test.dbf' select * from customers where city = :city"" import.ExecuteWithEvents(stat, EventScript)
The SQL::ImportStatement object supports UpdateBegin(), UpdateEnd(), and UpdateProgress().
Properties
- ArgumentsSQL::Arguments
Arguments for the current query.
- CallResultSQL::CallResult
Call results.
- ColumnReferencesReferenceList of SQL::Query::ColumnReference
An array of all column references in the query (including nested occurrences).
- ConnectionSQL::Connection
Current open connection
- DBFDefinitionCharacter
An optional definition for the local table (can override size and name, but must be type compatible with the corresponding column data type being imported)
- ErrorColumnNumeric
The column number of the last error reported by the parser.
- ErrorTextCharacter
The text of the last parser error reported.
- FunctionReferencesReferenceList of SQL::Query::ValueExpression
An array of all function calls. Behaves the same way as the SelectTableReference object.
- ObjectDefinitionsCharacter
For Debugging. Returns a string description of the mapping between the ANTLR grammar and the Xbasic objects.
- ParseTreeCharacter
For Debugging. A string description of the underlying parse tree.
- SQLStatementCharacter
A variable that can be assigned a syntax string without parsing it. If no value is passed to the Parse() method, this value is used.
- ReplaceOptionSQL::Query::ReplaceOption
Append or Replace
- TableCharacter
The table to be imported into.
- TokenTypeNameCharacter
Mode E. For SQL::Query, this property returns "Query".
- SourceSQL::SelectStatementSQL::Query::TableReference
The table reference or the select statement that defines the source of the data.
- XMLCharacter
Creates XML from the parse tree or recreates the tree from the XML.
Methods
- Execute Method
Execute the current statement using the current or passed connection.
- ExecuteWithEvents Method
Execute the current statement using the current or passed connection handling events with the script provided.
- Format Method
Format the original source (by default, lines are broken at significant keywords)..
- OpenConnection Method
Generate a native SQL statement using the selected syntax associated with the current or passed connection.
- Parse Method
Parse the SQLStatement passed (or the value previously set into the SQLStatement property).
- ReleaseConnection Method
Clear out the connection property.
- Reset Method
Reset the query as if it had just been created.
- Validate Method
Execute the current statement using the current or passed connection.
See Also