Xbasic

SQL::InsertStatement Object

Description

The SQL::InsertStatement object encapsulates the parsing and properties of a SQL INSERT statement. as a result, it has the most properties. Its children are the various clauses that make up a complete INSERT statement.

 Example

The following script inserts a new record.

dim conn as SQL::Connection
dim ins as SQL::InsertStatement
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. ins.parse(sql_insert) THEN
    ui_msg_box("Error", ins.callresult.text)
    end
END IF

Insert the new record into the table.

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

Methods

Execute Method

Execute the current statement using the current or passed connection.

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