ODBC Driver for Oracle Sales

Build 21.0.7930

Updating Data

The following code examples show how to use data modification statements.

Procedure for Updates

Use SQLExecDirect to execute data manipulation statements and use the SQLRowCount function to obtain the affected rows.

INSERT

To insert updates:

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); 
SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); 
SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); 
SQLDriverConnect(hdbc, 0, (SQLCHAR*)"Dsn=CData OracleSalesCloud Source;", SQL_NTS, 0, 0, 0, 0);
SQLExecDirect(hstmt, (SQLCHAR*)"INSERT INTO Opportunities (Name) VALUES ('Commercial Oppty')", SQL_NTS);  
SQLINTEGER  rowCount = 0;
SQLRowCount(hstmt, &rowCount);

UPDATE

To retrieve updates:

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); 
SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); 
SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); 
SQLDriverConnect(hdbc, 0, (SQLCHAR*)"Dsn=CData OracleSalesCloud Source;", SQL_NTS, 0, 0, 0, 0);
SQLExecDirect(hstmt, (SQLCHAR*)"UPDATE Opportunities SET Name='Commercial Oppty' WHERE CreatedBy='Jack')", SQL_NTS);  
SQLINTEGER  rowCount = 0;
SQLRowCount(hstmt, &rowCount); 

DELETE

To delete updates:

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); 
SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); 
SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); 
SQLDriverConnect(hdbc, 0, (SQLCHAR*)"Dsn=CData OracleSalesCloud Source;", SQL_NTS, 0, 0, 0, 0);
SQLExecDirect(hstmt, (SQLCHAR*)"DELETE FROM Opportunities WHERE Id='300000002693011')", SQL_NTS);  
SQLINTEGER  rowCount = 0;
SQLRowCount(hstmt, &rowCount); 

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930