13 VFP function SPT

Visual FoxPro is built into the 13 to the beginning of the SQL function, we refer to them as SPT functions. This function is 13 completed all of the SQL Pass Though features of Visual FoxPro. From a functional point of view, we can divide them into five parts:
First, the connection functions:
connection establishment functions: SQLConnect (), SQLSTRINGCONNECT ()
SQLDisconnect (): Disconnect function connected
to perform the function Second, the core:
SQL statement and transmission executing a function: SqlExec (), SqlPrapare ()
to obtain the function in batch mode more datasets: SqlMoreResults ()
undo function SPT asynchronous mode being executed: sqlCancel ()
Third, the transaction functions:
SQLCommit (), SQLROLLBACK ()
Fourth, the connection channel attribute functions:
SQLGETPROP (), SQLSETPROP ()
information taken five functions, a data source:
SQLTables (), SQLColumns ()

Usage: SQLEXEC (nConnectionHandle, [cSQLCommand, [cCursorName]])
Example: the SQLEXEC (Hconn, "the SELECT * the FROM the EMPLOYEES", "MyCursor")
the Browse
Example: SQLEXEC (hconn, "") && an empty command is sent, returns 1 if proof connection is available!
The method of the variable transmission:
a) The first is the use of: a question mark + variable; the present method need not worry about the type of the variable.
2) The second is TransForm () will merge variables to the statement.

The data set to be updated:
the Visual FoxPro cursor types: read-only cursor, the cursor can be read, update the cursor can be
1) a read-only cursor is a cursor that can not be modified, using SQL-Select statement results in VFP typical of read-only cursor is the cursor; such as: * the FROM the ORDERS the SELECT MyCursor the iNTO cURSOR
2) that is readable and writable cursor can read and write, the data is changed on the cursor to the cursor is not reflected in the data source;
a, a is () obtained by SQLEXEC cursor;
B, and the second is more VFP7 SQL-Select statement added readwrite cursor key generated;
such as: * the FROM the ORDERS the SELECT rEADWRITE the INTO cURSOR MyCursor
C, the third is "not set send update" local view and a remote view; (. SendUpdate property is .F)
. 3) is updatable cursors that can read and write, and no changes will be reflected in the cursor data from data sources;
typical updatable cursor is updatable view
to the SQLEXEC () obtained in the result set is set to the updatable cursor five steps:
A. the CURSORSETPROP ( "tABLES", a data source name table can be updated cursor name)
B. cURSOR SETPROP ( "KEYFIELDLIST", the key field updatable cursor name)
C. the CURSORSETPROP ( "UpdatableFieldList" can be updated field list, updatable cursor name)
D. the CURSORSETPROP ( "UpdateNameList", a list of correspondence between the anterior and posterior segment fields can be updated The cursor name)
E. CURSORSETPROP ( "SENDUPDATES",. T., Updatable cursor name)
a very important attribute --WhereType
when we set after the result set is updatable cursor, there is an important attribute is not set, it is WhereType. That is, based on the generated Where words, there are four cases:
the CURSORSETPROP ( "the WhereType",. 1) && keyword
CURSORSETPROP ( "WhereType", 2) && keyword + updatable fields
CURSORSETPROP ( "WhereType", 3) && + updated keyword field
CURSORSETPROP ( "WhereType", 4) && + timestamp keyword
, such as: the SQLCONNECT CNN = ( "Northwind")
the SQLEXEC (CNN, "ID aS SELECT CategoryID, CategoryName, from the Categories Description", " MyCursor ")
the SELECT MyCursor
the CURSORSETPROP (" the Tables "," the Categories "," MyCursor ")
the CURSORSETPROP (" KeyFieldList "," the above mentioned id "," MyCursor ")
the CURSORSETPROP ("
CURSORSETPROP("UpdateNameList","id categories.categoryid,categoryname categories.categoryname,"+ "description categories.description","mycursor")
CURSORSETPROP("SendUpdates" ,.t.,"mycursor")
CURSORSETPROP("WhereType" ,3)

Guess you like

Origin www.cnblogs.com/hnllhq/p/12293566.html