Xbasic

SQL::Statement Object

Description

The SQL::Statement object encapsulates the parsing and properties of a SQL SELECT, INSERT, UPDATE, or DELETE statement. as a result, it's properties will change depending on the last successfully processed SQL statement. Look at the related SQL::Query, SQL::InsertStatement, SQL::UpdateStatement, or SQL::DeleteStatement objects for available properties in each of these cases.

Example 

The following script inserts a new record.

dim conn as SQL::Connection
dim stat as SQL::Statement
dim qry as SQL::Query
dim rs as SQL::ResultSet
dim cs as SQL::CallResult
dim connString as C
dim sql_insert as C
dim sql_query as C

Next, define the connection string and the SQL INSERT statement. Note the syntax of the command. The fields that will receive data and the corresponding values are in two comma delimited sets.

connString = "{A5API='Access', FileName='c:\program files\a5v7\mdbfiles\alphasports.mdb'}"sql_insert = "insert into customer (firstname, lastname, bill_city, bill_postal_code, bill_state_region) values ('George', 'Jones', 'Arlington', '02000', 'VA')"

Open the connection and parse the insert command.

IF .not. conn.open(connString) THEN
    end
END IF
IF .not. stat.parse(sql_insert) THEN
    ui_msg_box("Error", stat.callresult.text)
    end
END IF

Insert the new record into the table.

stat.execute(conn)
cs = stat.CallResult
ui_msg_box("Call result", cs.Text)

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). Behaves the same way as .SelectTableReferences.

ConnectionSQL::Connection

Current open connection

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 .SelectTableReferences.

ObjectDefinitionsCharacter

For internal debugging. Returns a string description of the mapping between the ANTLR grammar and the Xbasic objects.

ParseTreeCharacter

For internal 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.

TokenTypeNameCharacter

For a SQL::Query object this property returns "Query", and so on. If no statement has been parsed, this property returns "Statement".

XMLCharacter

Creates XML from the tree or recreates the tree from the XML.

Methods

Execute Method

Execute the current statement using the current or passed connection. Optionally providing argument values as an object or as XML.

GenerateNativeSyntax 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).

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