Whats New with Data and SQL in Visual FoxPro 9.0 Data Language, Datatypes, CursorAdapter &...
-
Upload
susan-hamilton -
Category
Documents
-
view
248 -
download
0
Transcript of Whats New with Data and SQL in Visual FoxPro 9.0 Data Language, Datatypes, CursorAdapter &...
Whats New with Data and Whats New with Data and SQL in Visual FoxPro 9.0SQL in Visual FoxPro 9.0
Data Language, Datatypes, Data Language, Datatypes, CursorAdapter & XMLAdapterCursorAdapter & XMLAdapter
Overview: What’s New with Overview: What’s New with Data?Data?
SQLSQL MORE!MORE! Enhanced sub-query Enhanced sub-query
supportsupport Enhanced correlation Enhanced correlation
supportsupport Enhanced UNION supportEnhanced UNION support
PerformancePerformance Commands & FunctionsCommands & Functions DatatypesDatatypes
Remote DataRemote Data CursorAdapterCursorAdapter XMLAdapterXMLAdapter SQL Pass-through (SPT)SQL Pass-through (SPT) OLEDB Provider OLEDB Provider
EnhancementsEnhancements
SQL - More!SQL - More!
Amount of JOINs and amount of sub-Amount of JOINs and amount of sub-queries in SQL statement. .queries in SQL statement. .
Amount of UNIONs in SQL SELECT Amount of UNIONs in SQL SELECT statement. statement.
Amount of tables referenced by SQL Amount of tables referenced by SQL statement. statement.
More than 24 items in IN list. More than 24 items in IN list. Multiple sub-query nesting.Multiple sub-query nesting.
* No hard coded limit!
SQL - Enhanced sub-query SQL - Enhanced sub-query supportsupport
Sub-query in Sub-query in SELECTSELECT list (projection). list (projection). Sub-query in Sub-query in FROMFROM clause (derived). clause (derived). Sub-query in UPDATE SET list. Sub-query in UPDATE SET list. ORDER BY in conjunction with TOP N ORDER BY in conjunction with TOP N
inside of non-correlated sub-queryinside of non-correlated sub-query Support for more complex expressions Support for more complex expressions
on the left side in comparison with sub-on the left side in comparison with sub-queryquery
SQL - Enhanced correlation SQL - Enhanced correlation supportsupport
Correlated UPDATE … FROM . Correlated UPDATE … FROM . Correlated DELETE … FROM . Correlated DELETE … FROM . GROUP BY in correlated sub-queryGROUP BY in correlated sub-query
SELECT * ;SELECT * ; FROM foo1 T1 ; FROM foo1 T1 ; WHERE f1 IN (SELECT MAX(f1); WHERE f1 IN (SELECT MAX(f1); FROM foo2 T2 ; FROM foo2 T2 ; WHERE T2.f2 = T1.f2; WHERE T2.f2 = T1.f2; GROUP BY f3) GROUP BY f3)
SQL - Enhanced UNION SQL - Enhanced UNION supportsupport
UNION in INSERT INTO ... SELECT ... UNION in INSERT INTO ... SELECT ... FROM ... FROM ...
ORDER BY <field name> when using ORDER BY <field name> when using UNIONUNION Referenced fields must be present in Referenced fields must be present in
SELECT list for the last SELECT in the SELECT list for the last SELECT in the UNION.UNION.
PerformancePerformance
TOP N performance improvement TOP N performance improvement MIN()/MAX() optimization MIN()/MAX() optimization Rushmore optimization changes Rushmore optimization changes
LIKE LIKE INDEX ON DELETED() / NOT DELETED()INDEX ON DELETED() / NOT DELETED()
INDEX ON…FOR DELETED() / NOT DELETED()INDEX ON…FOR DELETED() / NOT DELETED()
Rushmore OptimizationRushmore Optimization
INDEX ON !DELETED() will be used to INDEX ON !DELETED() will be used to optimize !DELETED() or DELETED() optimize !DELETED() or DELETED() conditions when INDEX ON DELETED() is conditions when INDEX ON DELETED() is not present.not present.
INDEX ON <…> FOR !DELETED() will be INDEX ON <…> FOR !DELETED() will be used to optimize !DELETED() or DELETED() used to optimize !DELETED() or DELETED() when neither INDEX ON DELETED() or when neither INDEX ON DELETED() or INDEX ON !DELETED() is present.INDEX ON !DELETED() is present.
Rushmore OptimizationRushmore Optimization
When ever it is possible to determine that a When ever it is possible to determine that a Query should filter on DELETED() or !Query should filter on DELETED() or !DELETED() a filtered index FOR DELETED() DELETED() a filtered index FOR DELETED() or FOR !DELETED() will be used accordingly or FOR !DELETED() will be used accordingly if no non-filtered index exists.if no non-filtered index exists.
If only indexes filtered FOR !DELETED() were If only indexes filtered FOR !DELETED() were used for Rushmore optimization and SET used for Rushmore optimization and SET DELETED is ON, additional !DELETED() DELETED is ON, additional !DELETED() optimization is not done as it is optimization is not done as it is unnecessary.unnecessary.
Language EnhancementsLanguage Enhancements
BINARY index type …BINARY index type …
SET REFRESH changesSET REFRESH changes
CursorSetProp("Refresh") .CursorSetProp("Refresh") .
SYS(1104,[cAlias | nWorkarea])SYS(1104,[cAlias | nWorkarea])
FLUSH [{ IN<nWorkArea>|<cTableAlias>}|<cFileSpec>] [ FORCE ]FLUSH [{ IN<nWorkArea>|<cTableAlias>}|<cFileSpec>] [ FORCE ]
SYS(3092) output to a fileSYS(3092) output to a file
SET SQLBUFFERING / SELECT … WITH (Buffering = <lexpr>)SET SQLBUFFERING / SELECT … WITH (Buffering = <lexpr>)
CAST()CAST()
ICASE()ICASE()
New DatatypesNew DatatypesVarCharVarChar
Similar to char data type except filled Similar to char data type except filled value is not padded (or trimmed) with value is not padded (or trimmed) with spaces if value is assigned explicitly or by spaces if value is assigned explicitly or by means of default value.means of default value.
Fields from external sources that do not fit Fields from external sources that do not fit into Varchar limits will map to Memo.into Varchar limits will map to Memo.
VarChar has priority over CharacterVarChar has priority over Character Index has same structure as CharacterIndex has same structure as Character Uses:Uses:
Reduce size of indexesReduce size of indexes With SQL Server VarChar (when < 254 bytes)With SQL Server VarChar (when < 254 bytes)
New DatatypesNew DatatypesVarBinaryVarBinary
Similar to VarChar except used to Similar to VarChar except used to store binary data.store binary data.
NO CPTRANSNO CPTRANS Uses:Uses:
TimeStamp (native)TimeStamp (native) GUIDGUID Map to VarBinary in SQL ServerMap to VarBinary in SQL Server
New DatatypesNew DatatypesBLOBBLOB
Similar to Memo data type except it’s Similar to Memo data type except it’s treated as a true binary data type. treated as a true binary data type.
NO CPTRANSNO CPTRANS MODI MEMO displays HEX dumpMODI MEMO displays HEX dump SCATTER/GATHER MEMOSCATTER/GATHER MEMO Uses:Uses:
Image.PictureVal (Goodbye General!)Image.PictureVal (Goodbye General!) Map to BLOB in SQL ServerMap to BLOB in SQL Server
Comparison rulesComparison rules
Type on Left Padding Case SensitiveType on Left Padding Case Sensitive------------- --------- ---------------------------- --------- ---------------Binary CHR(0) AlwaysBinary CHR(0) AlwaysCharacter CHR(32) SET COLLATE dependentCharacter CHR(32) SET COLLATE dependent
New DatatypesNew DatatypesSET EXACT & Binary DataSET EXACT & Binary Data
SET COLLATE TO MACHINESET COLLATE TO MACHINESET EXACT OFFSET EXACT OFF expression C=C Q=C C=Q Q=Q expression C=C Q=C C=Q Q=Q--------------- --- --- --- ------------------ --- --- --- ---"abc" = "abc" .T. .T. .T. .T."abc" = "abc" .T. .T. .T. .T."abc " = "abc" .T. .T. .T. .T."abc " = "abc" .T. .T. .T. .T."abc" = "abc " .F. .F. .F. .F."abc" = "abc " .F. .F. .F. .F."abc" = "ABC" .F. .F. .F. .F."abc" = "ABC" .F. .F. .F. .F."ABC" = "abc" .F. .F. .F. .F."ABC" = "abc" .F. .F. .F. .F.
SET COLLATE TO MACHINESET COLLATE TO MACHINESET EXACT ONSET EXACT ON expression C=C Q=C C=Q Q=Q expression C=C Q=C C=Q Q=Q--------------- --- --- --- ------------------ --- --- --- ---"abc" = "abc" .T. .T. .T. .T."abc" = "abc" .T. .T. .T. .T."abc " = "abc" .T. .F. .T. .F."abc " = "abc" .T. .F. .T. .F."abc" = "abc " .T. .F. .T. .F."abc" = "abc " .T. .F. .T. .F."abc" = "ABC" .F. .F. .F. .F."abc" = "ABC" .F. .F. .F. .F."ABC" = "abc" .F. .F. .F. .F."ABC" = "abc" .F. .F. .F. .F.
SET COLLATE TO GENERAL SET COLLATE TO GENERAL SET EXACT OFFSET EXACT OFF
expression C=C Q=C C=Q Q=Q expression C=C Q=C C=Q Q=Q--------------- --- --- --- ------------------ --- --- --- ---"abc" = "abc" .T. .T. .T. .T."abc" = "abc" .T. .T. .T. .T."abc " = "abc" .T. .T. .T. .T."abc " = "abc" .T. .T. .T. .T."abc" = "abc " .F. .F. .F. .F."abc" = "abc " .F. .F. .F. .F."abc" = "ABC" .T. .F. .T. .F."abc" = "ABC" .T. .F. .T. .F."ABC" = "abc" .T. .F. .T. .F."ABC" = "abc" .T. .F. .T. .F.
SET COLLATE TO GENERALSET COLLATE TO GENERALSET EXACT ON SET EXACT ON
expression C=C Q=C C=Q Q=Q expression C=C Q=C C=Q Q=Q--------------- --- --- --- ------------------ --- --- --- ---"abc" = "abc" .T. .T. .T. .T."abc" = "abc" .T. .T. .T. .T."abc " = "abc" .T. .F. .T. .F."abc " = "abc" .T. .F. .T. .F."abc" = "abc " .T. .F. .T. .F."abc" = "abc " .T. .F. .T. .F."abc" = "ABC" .T. .F. .T. .F."abc" = "ABC" .T. .F. .T. .F."ABC" = "abc" .T. .F. .T. .F."ABC" = "abc" .T. .F. .T. .F.
Remote DataRemote Data
DisconnectRollbackDisconnectRollback Determines whether pending transaction has Determines whether pending transaction has
to be rolled back when connection is being to be rolled back when connection is being disconnected. default (.F.) disconnected. default (.F.)
RecordsFetchedRecordsFetched Returns amount of records currently fetched Returns amount of records currently fetched
from the back end for ODBC/ADO based cursor.from the back end for ODBC/ADO based cursor. FetchIsCompleteFetchIsComplete
Returns .T. if fetch process for the ODBC/ADO Returns .T. if fetch process for the ODBC/ADO based cursor is complete.based cursor is complete.
SPTSPT
Ability to determine amount of records Ability to determine amount of records affected by an SPT execution.affected by an SPT execution. Via additional parameter for SQLEXEC and Via additional parameter for SQLEXEC and
SQLMORERESULTS functions:SQLMORERESULTS functions: aCountInfo – aCountInfo – Provides name of the array to populate Provides name of the array to populate
with row count information. Array contains two with row count information. Array contains two columns: 1 – columns: 1 – AliasAlias, 2 –, 2 –CountCount. .
SQLIDLEDISCONNECT function SQLIDLEDISCONNECT function Similar behavior to implicit disconnect based Similar behavior to implicit disconnect based
on IdleTimeOut property, now it can be done on IdleTimeOut property, now it can be done explicitly.explicitly.
The function fails if statement handle is busy or The function fails if statement handle is busy or connection is in manual commit mode.connection is in manual commit mode.
OLEDB ProviderOLEDB Provider
Return Rowset from a stored Return Rowset from a stored procedure.procedure. SetResultSet / GetResultSet / SetResultSet / GetResultSet /
ClearResultSetClearResultSet When used in native VFP, return When used in native VFP, return
value is the alias of the returned value is the alias of the returned rowset.rowset.
CursorAdapterCursorAdapter
Support for TIMESTAMP fieldsSupport for TIMESTAMP fields TimestampFieldListTimestampFieldList
Auto-refresh supportAuto-refresh support On demand record refreshOn demand record refresh
ca.RecordRefresh([nRecords],[nRecordOffset]) ca.RecordRefresh([nRecords],[nRecordOffset]) Delayed Memo fetch Delayed Memo fetch DEFAULT and CHECK constraints DEFAULT and CHECK constraints MapVarChar / MapBinaryMapVarChar / MapBinary
XMLAdapterXMLAdapter
Support for hierarchical XMLSupport for hierarchical XML Support for XPath expressions.Support for XPath expressions. XML encoding/decoding XML encoding/decoding
enhancementsenhancements
RecommendationRecommendation
Taming Visual FoxPro‘s SQLTaming Visual FoxPro‘s SQLReal World Data Solutions For VFPReal World Data Solutions For VFPTamar E. Granor with Della MartinTamar E. Granor with Della MartinHentzenwerke PublishingHentzenwerke Publishing
Special offer 20 EURO for mass orderSpecial offer 20 EURO for mass orderbut only if you are interested…but only if you are interested…