Visual DataFlex 11.x allows for the QODBC tables to be supported through the ODBC_DRV that's part of the Studio with alpha numeric (ASCII) unique identifiers (record_number) . The normal method is to open the Studio and the workspace, select Database Builder and using the Database pulldown "Connect to ODBC Database...", the select either the table you're interested in or the entire database. The wizard will then create the DDs for you that you can use within the Studio as regular tables.
As far as using Embedded SQL, here are a couple of component examples you can use within a view:
/ This view demonstrates the topics in Chapter 3 of // the Embedded SQL User's Guide: // - Shows the message interface and the command interface // - Shows the query: // Select ListID, Name, FullName from customer where IsActive = 1;
Use Windows.pkg Use ODBC_DRV.pkg Use SQL.pkg
/* DO NOT REMOVE THIS LINE: IDE GENERATED CODE WILL GO HERE */ #Replace CS_CONNECT "DSN=QuickBooks Data" #Replace CS_QUERY "Select ListID, Name, FullName from customer where IsActive = 1;"
// Procedure: MessageInterface // Purpose : Execute the query and show its results using the message interface Procedure MessageInterface String sID sName sFullName sLineFeed Handle hoSQL hDbc hStmt Integer iFetchResult
Move (Character(10)) To sLineFeed
//*** The SQL handle manager object Object oSQLHandler Is A cSQLHandleManager Move Self To hoSQL End_Object // oSQLHandler
//*** Connect to the database server Send SQLSetConnect Of hoSQL ODBC_DRV_ID CS_CONNECT Get SQLConnect Of hoSQL "" "" To hDbc If (hDbc <> 0) Begin //*** Open a statement Get SQLOpen Of hDbc To hStmt If (hStmt <> 0) Begin //*** Execute the statement, we do it only once so use direct //*** execution Send SQLExecDirect Of hStmt CS_QUERY
//*** Traverse the result set Repeat Get SQLFetch Of hStmt To iFetchResult If (iFetchResult <> 0) Begin Get SQLColumnValue Of hStmt 1 To sID Get SQLColumnValue Of hStmt 2 To sName Get SQLColumnValue Of hStmt 3 To sFullName Send Insert Of oResults (sID+", "+sName+", "+sFullName+sLineFeed+sLineFeed) End Until (iFetchResult = 0) Send SQLClose Of hStmt End Send SQLDisconnect Of hDbc End
//*** Destory the SQL handle manager object Send Destroy_Object Of hoSQL End_Procedure // MessageInterface
// Procedure: CommandInterface // Purpose : Execute the query and show its results using the command interface Procedure CommandInterface String sID sName sFullName sLineFeed Handle hoSQL hDbc hStmt
Move (Character(10)) To sLineFeed
//*** Connect to the database server SQLSetConnect ODBC_DRV_ID CS_CONNECT SQLConnect To hDbc If (hDbc <> 0) Begin //*** Open a statement SQLOpen hDbc To hStmt If (hStmt <> 0) Begin //*** Execute the statement, we do it only once so use direct //*** execution SQLExecDirect hStmt CS_QUERY
//*** Traverse the result set Repeat SQLFetch hStmt To sID sName sFullname If (SQLResult <> 0) Begin Send Insert Of oResults (sID+", "+sName+", "+sFullName+sLineFeed) End Until (SQLResult = 0) SQLClose hStmt End SQLDisconnect hDbc End End_Procedure // CommandInterface
Procedure TestMessageInterface Send Delete_Data Of oResults Send MessageInterface End_Procedure // TestMessageInterface
Procedure TestCommandInterface Send Delete_Data Of oResults Send CommandInterface End_Procedure // TestCommandInterface
The forum contains many examples of the INSERT statements you can use through the Visual DataFlex command interface. For example, see: How do I add customers?
|