home *** CD-ROM | disk | FTP | other *** search
- /*
- * winsam.pc
- *
- * Example Pro*C Application for Windows V3.0.
- *
- * by F. Lopez -- Desktop Products Division.
- *
- * Copyright 1991, Oracle Corporation.
- * Modified -
- * Criswell 3/11/91 - Include sqlproto.h
- */
-
- #include <windows.h>
- #include "winsam.h"
- #include <string.h>
- #include <sqlproto.h>
-
-
- /********************************************************************/
- /* Pro*C Declaration Section */
- /********************************************************************/
- /* You cannot use typedef's or the "C" macro facilities in the */
- /* Pro*C declare section. No constant folding either. */
- /********************************************************************/
- EXEC SQL BEGIN DECLARE SECTION;
-
- /* Input host variables for logging into ORACLE. */
- VARCHAR vc_connect[ 21 ]; /*used by CONNECT statement*/
- VARCHAR vc_password[ 21 ]; /*used by CONNECT statement*/
- VARCHAR vc_userid[ 21 ]; /*used by CONNECT statement*/
-
- /* Input/Output host variables for EMP table. */
- VARCHAR vc_emp_empno[ 5 ]; /*used for EMP table*/
- VARCHAR vc_emp_ename[ 11 ]; /*used for EMP table*/
- VARCHAR vc_emp_job[ 10 ]; /*used for EMP table*/
- VARCHAR vc_emp_mgr[ 5 ]; /*used for EMP table*/
- VARCHAR vc_emp_hiredate[ 10 ]; /*used for EMP table*/
- VARCHAR vc_emp_sal[ 9 ]; /*used for EMP table*/
- VARCHAR vc_emp_comm[ 9 ]; /*used for EMP table*/
- VARCHAR vc_emp_deptno[ 3 ]; /*used for EMP table*/
-
- /* Null field indicators for table EMP. */
- short ind_emp_empno; /*used for EMP table*/
- short ind_emp_ename; /*used for EMP table*/
- short ind_emp_job; /*used for EMP table*/
- short ind_emp_mgr; /*used for EMP table*/
- short ind_emp_hiredate; /*used for EMP table*/
- short ind_emp_sal; /*used for EMP table*/
- short ind_emp_comm; /*used for EMP table*/
- short ind_emp_deptno; /*used for EMP table*/
-
- EXEC SQL END DECLARE SECTION;
-
- EXEC SQL INCLUDE SQLCA.H;
- EXEC SQL INCLUDE SQLDA.H;
-
- extern SQLDA *sqlald();
-
-
- /********************************************************************/
- /* Windows Declaration Section */
- /********************************************************************/
-
- char szAbout[ MAX_ABOUT_STRING + 1 ];
- char szAppName[ MAX_APPNAME_STRING + 1 ];
- char szSampleMenu[ MAX_SAMPLEMENU_STRING + 1 ];
- char szTitle[ MAX_TITLE_STRING + 1 ];
-
- long FAR PASCAL SampleWndProc(HWND, unsigned, WORD, LONG);
-
- int DoDisconnect(HWND);
- int DoEmployees(HANDLE, HWND);
- int DoLogon(HANDLE, HWND);
- PROCEDURE GetEmpRecord(HWND);
- BOOL ProcessOracleErrorCode(HWND);
- BOOL SampleInit(HANDLE);
- PROCEDURE SetEmpRecord(HWND);
-
- static HANDLE hInst;
- HWND hwndMain;
- FARPROC lpprocAbout;
- FARPROC lpprocLogon;
-
- struct oracle_session session;
-
-
- /********************************************************************/
- /* Pro*C and Windows Code. */
- /********************************************************************/
-
- /*
- *ProcessOracleErrorCode
- */
- BOOL ProcessOracleErrorCode(hWnd)
- HWND hWnd;
- {
-
- /* Check for a Pro*C error -- sqlcodes less than zero are errors. */
- if (sqlca.sqlcode < 0) {
- MessageBox(hWnd, sqlca.sqlerrm.sqlerrmc, "ORACLE Error", MB_OK);
- return( FALSE );
- } /*if*/
-
- return( TRUE );
-
- } /*ProcessOracleErrorCode*/
-
- /*
- *AboutDlg
- */
- BOOL FAR PASCAL AboutDlg(hDlg, message, wParam, lParam)
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
-
- switch (message) {
-
- case WM_COMMAND :
- EndDialog(hDlg, TRUE);
- return(TRUE);
-
- case WM_INITDIALOG :
- return(TRUE);
-
- default :
- return(FALSE);
- } /*switch*/
-
- return(FALSE);
-
- } /*AboutDlg*/
-
- /*
- *GetEmpRecord
- */
- PROCEDURE GetEmpRecord(hDlg)
- HWND hDlg;
- {
-
- ind_emp_empno = ind_emp_ename = ind_emp_job = ind_emp_mgr =
- ind_emp_hiredate = ind_emp_sal = ind_emp_comm = ind_emp_deptno = 0;
-
- if ((vc_emp_empno.len = GetDlgItemText(hDlg, ID_EMPLOYEES_FLD_EMPNO,
- (LPSTR)vc_emp_empno.arr, 5)) == 0)
- ind_emp_empno = -1;
-
- if ((vc_emp_ename.len = GetDlgItemText(hDlg, ID_EMPLOYEES_FLD_ENAME,
- (LPSTR)vc_emp_ename.arr, 11)) == 0)
- ind_emp_ename = -1;
-
- if ((vc_emp_job.len = GetDlgItemText(hDlg, ID_EMPLOYEES_FLD_JOB,
- (LPSTR)vc_emp_job.arr, 10)) == 0)
- ind_emp_job = -1;
-
- if ((vc_emp_mgr.len = GetDlgItemText(hDlg, ID_EMPLOYEES_FLD_MGR,
- (LPSTR)vc_emp_mgr.arr, 5)) == 0)
- ind_emp_mgr = -1;
-
- if ((vc_emp_hiredate.len = GetDlgItemText(hDlg, ID_EMPLOYEES_FLD_HIREDATE,
- (LPSTR)vc_emp_hiredate.arr, 10)) == 0)
- ind_emp_hiredate = -1;
-
- if ((vc_emp_sal.len = GetDlgItemText(hDlg, ID_EMPLOYEES_FLD_SAL,
- (LPSTR)vc_emp_sal.arr, 9)) == 0)
- ind_emp_sal = -1;
-
- if ((vc_emp_comm.len = GetDlgItemText(hDlg, ID_EMPLOYEES_FLD_COMM,
- (LPSTR)vc_emp_comm.arr, 9)) == 0)
- ind_emp_comm = -1;
-
- if ((vc_emp_deptno.len = GetDlgItemText(hDlg, ID_EMPLOYEES_FLD_DEPTNO,
- (LPSTR)vc_emp_deptno.arr, 3)) == 0)
- ind_emp_deptno = -1;
-
- return;
-
- } /*GetEmpRecord*/
-
- /*
- *SetEmpRecord
- */
- PROCEDURE SetEmpRecord(hDlg)
- HWND hDlg;
- {
-
- SetDlgItemText(hDlg, ID_EMPLOYEES_FLD_EMPNO, (LPSTR)vc_emp_empno.arr);
- SetDlgItemText(hDlg, ID_EMPLOYEES_FLD_ENAME, (LPSTR)vc_emp_ename.arr);
- SetDlgItemText(hDlg, ID_EMPLOYEES_FLD_JOB, (LPSTR)vc_emp_job.arr);
- SetDlgItemText(hDlg, ID_EMPLOYEES_FLD_MGR, (LPSTR)vc_emp_mgr.arr);
- SetDlgItemText(hDlg, ID_EMPLOYEES_FLD_HIREDATE,
- (LPSTR)vc_emp_hiredate.arr);
- SetDlgItemText(hDlg, ID_EMPLOYEES_FLD_SAL, (LPSTR)vc_emp_sal.arr);
- SetDlgItemText(hDlg, ID_EMPLOYEES_FLD_COMM, (LPSTR)vc_emp_comm.arr);
- SetDlgItemText(hDlg, ID_EMPLOYEES_FLD_DEPTNO, (LPSTR)vc_emp_deptno.arr);
-
- return;
-
- } /*SetEmpRecord*/
-
- /*
- *EmployeesDlg
- */
- BOOL FAR PASCAL EmployeesDlg(hDlg, message, wParam, lParam)
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
- int iReturn = TRUE;
-
- /* DECLARE is a declaration and it will not generate "C" right here. */
- EXEC SQL DECLARE emp_cursor CURSOR FOR
- SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO
- FROM EMP
- FOR UPDATE OF EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO;
-
- /****************************************************************/
- /* You need the "FOR UPDATE OF" clause so that you can use */
- /* the "FOR CURRENT OF" with UPDATE and DELETE statements. This */
- /* also applies to an OCI cursor's ROWID field. This field will */
- /* only be valid for other statements to use if and only if you */
- /* use the "FOR UPDATE OF" clause with the SELECT for this locks*/
- /* the ROWID until the next COMMIT [see SQL manuals]. */
- /****************************************************************/
-
- switch (message) {
-
- case WM_COMMAND :
-
- switch (wParam) {
-
- case ID_EMPLOYEES_EXIT :
- EndDialog(hDlg, 1);
- break;
-
- case ID_EMPLOYEES_SELECT :
-
- if (session.opened == TRUE)
- EXEC SQL CLOSE emp_cursor;
-
- EXEC SQL OPEN emp_cursor;
-
- /* Check for error. */
- if (ProcessOracleErrorCode(hDlg) == FALSE)
- break;
-
- session.opened = TRUE;
-
- case ID_EMPLOYEES_FETCH :
-
- if (session.opened == FALSE) {
- MessageBox(hDlg, "No active set", "ORACLE", MB_OK);
- break;
- } /*if*/
-
- EXEC SQL
- FETCH emp_cursor
- INTO :vc_emp_empno:ind_emp_empno,
- :vc_emp_ename:ind_emp_ename,
- :vc_emp_job:ind_emp_job,
- :vc_emp_mgr:ind_emp_mgr,
- :vc_emp_hiredate:ind_emp_hiredate,
- :vc_emp_sal:ind_emp_sal,
- :vc_emp_comm:ind_emp_comm,
- :vc_emp_deptno:ind_emp_deptno;
-
- /* Check for no more data in active set. */
- if (sqlca.sqlcode == 1403) {
- MessageBox(hDlg, "No more data", "ORACLE", MB_OK);
- break;
- } /*if*/
-
- vc_emp_empno.arr[ vc_emp_empno.len ] = EOS;
- vc_emp_ename.arr[ vc_emp_ename.len ] = EOS;
- vc_emp_job.arr[ vc_emp_job.len ] = EOS;
- vc_emp_mgr.arr[ vc_emp_mgr.len ] = EOS;
- vc_emp_hiredate.arr[ vc_emp_hiredate.len ] = EOS;
- vc_emp_sal.arr[ vc_emp_sal.len ] = EOS;
- vc_emp_comm.arr[ vc_emp_comm.len ] = EOS;
- vc_emp_deptno.arr[ vc_emp_deptno.len ] = EOS;
-
- SetEmpRecord(hDlg);
-
- ProcessOracleErrorCode(hDlg);
- break;
-
- case ID_EMPLOYEES_INSERT :
- GetEmpRecord(hDlg);
-
- EXEC SQL
- INSERT INTO emp
- (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
- VALUES (:vc_emp_empno:ind_emp_empno,
- :vc_emp_ename:ind_emp_ename,
- :vc_emp_job:ind_emp_job,
- :vc_emp_mgr:ind_emp_mgr,
- :vc_emp_hiredate:ind_emp_hiredate,
- :vc_emp_sal:ind_emp_sal,
- :vc_emp_comm:ind_emp_comm,
- :vc_emp_deptno:ind_emp_deptno);
-
- ProcessOracleErrorCode(hDlg);
- break;
-
- case ID_EMPLOYEES_UPDATE :
-
- if (session.opened == FALSE) {
- MessageBox(hDlg, "No active set", "ORACLE", MB_OK);
- break;
- } /*if*/
-
- GetEmpRecord(hDlg);
-
- EXEC SQL
- UPDATE emp
- SET EMPNO = :vc_emp_empno:ind_emp_empno,
- ENAME = :vc_emp_ename:ind_emp_ename,
- JOB = :vc_emp_job:ind_emp_job,
- MGR = :vc_emp_mgr:ind_emp_mgr,
- HIREDATE = :vc_emp_hiredate:ind_emp_hiredate,
- SAL = :vc_emp_sal:ind_emp_sal,
- COMM = :vc_emp_comm:ind_emp_comm,
- DEPTNO = :vc_emp_deptno:ind_emp_deptno
- WHERE CURRENT OF emp_cursor;
-
- ProcessOracleErrorCode(hDlg);
- break;
-
-
- case ID_EMPLOYEES_DELETE :
-
- if (session.opened == FALSE) {
- MessageBox(hDlg, "No active set", "ORACLE", MB_OK);
- break;
- } /*if*/
-
- EXEC SQL
- DELETE FROM emp
- WHERE CURRENT OF emp_cursor;
-
- ProcessOracleErrorCode(hDlg);
- break;
-
- case ID_EMPLOYEES_CLEAR :
- vc_emp_empno.arr[ 0 ] = EOS; vc_emp_empno.len = 0;
- vc_emp_ename.arr[ 0 ] = EOS; vc_emp_ename.len = 0;
- vc_emp_job.arr[ 0 ] = EOS; vc_emp_job.len = 0;
- vc_emp_mgr.arr[ 0 ] = EOS; vc_emp_mgr.len = 0;
- vc_emp_hiredate.arr[ 0 ] = EOS; vc_emp_hiredate.len = 0;
- vc_emp_sal.arr[ 0 ] = EOS; vc_emp_sal.len = 0;
- vc_emp_comm.arr[ 0 ] = EOS; vc_emp_comm.len = 0;
- vc_emp_deptno.arr[ 0 ] = EOS; vc_emp_deptno.len = 0;
- SetEmpRecord(hDlg);
- break;
-
- case ID_EMPLOYEES_COMMIT :
- EXEC SQL COMMIT WORK;
-
- /* COMMIT frees locks so close the SELECT. */
- EXEC SQL CLOSE emp_cursor;
- session.opened = FALSE;
-
- ProcessOracleErrorCode(hDlg);
- break;
-
- case ID_EMPLOYEES_ROLLBACK :
- EXEC SQL ROLLBACK WORK;
-
- /* ROLLBACK frees locks so close the SELECT. */
- EXEC SQL CLOSE emp_cursor;
- session.opened = FALSE;
-
- ProcessOracleErrorCode(hDlg);
- break;
-
- default :
- iReturn = FALSE;
- break;
- } /*switch*/
-
- break;
-
- case WM_INITDIALOG :
- break;
-
- default :
- iReturn = FALSE;
- break;
- } /*switch*/
-
- return( iReturn );
-
- } /*EmployeesDlg*/
-
- /*
- *DoEmployees
- */
- int DoEmployees(hInst, hWnd)
- HANDLE hInst;
- HWND hWnd;
- {
- int iReturn = 0;
- FARPROC lpprocEmployeesDlg;
-
- lpprocEmployeesDlg = MakeProcInstance(EmployeesDlg, hInst);
-
- iReturn = DialogBox(hInst, MAKEINTRESOURCE( EMPLOYEESBOX ),
- hWnd, lpprocEmployeesDlg);
-
- FreeProcInstance(lpprocEmployeesDlg);
-
- return( iReturn );
-
- return 0;
-
- } /*DoEmployees*/
-
- /*
- * SampleInit
- *
- * Do startup initialization for the sample application.
- */
- BOOL SampleInit(in_hInst)
- HANDLE in_hInst;
- {
- WNDCLASS SampleClass;
-
- /* Load strings from resource */
- LoadString(in_hInst, IDS_ABOUT, (LPSTR)szAbout, MAX_ABOUT_STRING);
- LoadString(in_hInst, IDS_APPNAME, (LPSTR)szAppName, MAX_APPNAME_STRING);
- LoadString(in_hInst, IDS_SAMPLEMENU,
- (LPSTR)szSampleMenu, MAX_SAMPLEMENU_STRING);
- LoadString(in_hInst, IDS_TITLE, (LPSTR)szTitle, MAX_TITLE_STRING);
-
- SampleClass.style = CS_HREDRAW | CS_VREDRAW;
- SampleClass.lpfnWndProc = SampleWndProc;
- SampleClass.cbClsExtra = 0;
- SampleClass.cbWndExtra = 0;
- SampleClass.hInstance = in_hInst;
- SampleClass.hIcon = LoadIcon(in_hInst, (LPSTR)szAppName);
- SampleClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- SampleClass.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
- SampleClass.lpszMenuName = (LPSTR)szSampleMenu;
- SampleClass.lpszClassName = (LPSTR)szAppName;
-
- if (!RegisterClass((LPWNDCLASS)&SampleClass))
- return FALSE;
-
- return( TRUE );
-
- } /*SampleInit*/
-
- /*
- *WinMain
- */
- int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
- HANDLE hInstance, hPrevInstance;
- LPSTR lpszCmdLine;
- int cmdShow;
- {
- HMENU hmenuSystem, hmenuSample;
- HWND hWnd;
- MSG msg;
-
- if (hPrevInstance)
- return( FALSE );
-
- if (!SampleInit(hInstance))
- return( FALSE );
-
- /* Initialize the ORACLE connection. */
- session.connected = FALSE;
- session.opened = FALSE;
-
- hInst = hInstance;
-
- hmenuSample = LoadMenu(hInst, "SAMPLEMENU");
-
- hwndMain = hWnd = CreateWindow((LPSTR)szAppName,
- (LPSTR)szTitle,
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- (HWND)NULL,
- (HMENU)NULL,
- (HANDLE)hInst,
- (LPSTR)NULL);
-
- lpprocAbout = MakeProcInstance((FARPROC)AboutDlg, hInst);
- hmenuSystem = GetSystemMenu(hWnd, FALSE);
- InsertMenu(hmenuSystem, 0, MF_BYPOSITION | MF_STRING, IDS_ABOUT,
- (LPSTR)szAbout);
-
- ShowWindow(hWnd, SW_SHOWNORMAL);
- UpdateWindow(hWnd);
-
- while (GetMessage((LPMSG)&msg, NULL, 0, 0)) {
- TranslateMessage((LPMSG)&msg);
- DispatchMessage((LPMSG)&msg);
- } /*while*/
-
- return( (int)msg.wParam );
-
- } /*WinMain*/
-
- /*
- *SampleWndProc
- */
- long FAR PASCAL SampleWndProc(hWnd, message, wParam, lParam)
- HWND hWnd;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
- static HWND hInst;
- HMENU hmenuSample;
-
- switch (message) {
-
- case WM_CREATE :
- hInst = ((LPCREATESTRUCT) lParam)->hInstance;
- return TRUE;
-
- case WM_SYSCOMMAND :
-
- switch (wParam) {
- case IDS_ABOUT:
- DialogBox(hInst, MAKEINTRESOURCE(ABOUTBOX),
- hWnd, lpprocAbout);
- return TRUE;
- break;
-
- default:
- break;
- } /*switch*/
- break;
-
- case WM_COMMAND :
- if (LOWORD(lParam) == 0) { /*message from a menu*/
-
- switch (wParam) {
-
- case IDM_EXIT :
- SendMessage(hWnd, WM_CLOSE, 0, 0L);
- return( TRUE );
-
- case IDM_ORACLE_CONNECT :
- if (DoLogon(hInst, hWnd) == TRUE) {
- hmenuSample = GetMenu( hWnd );
- EnableMenuItem(hmenuSample, IDM_ORACLE_CONNECT,
- MF_GRAYED);
- EnableMenuItem(hmenuSample, IDM_ORACLE_DISCONNECT,
- MF_ENABLED);
- EnableMenuItem(hmenuSample, IDM_ORACLE_EMPLOYEES,
- MF_ENABLED);
- } /*if*/
- return( TRUE );
-
- case IDM_ORACLE_DISCONNECT :
- if (DoDisconnect(hWnd) == TRUE) {
- hmenuSample = GetMenu( hWnd );
- EnableMenuItem(hmenuSample, IDM_ORACLE_CONNECT,
- MF_ENABLED);
- EnableMenuItem(hmenuSample, IDM_ORACLE_DISCONNECT,
- MF_GRAYED);
- EnableMenuItem(hmenuSample, IDM_ORACLE_EMPLOYEES,
- MF_GRAYED);
- } /*if*/
- return( TRUE );
-
- case IDM_ORACLE_EMPLOYEES :
- DoEmployees(hInst, hWnd);
- return( TRUE );
-
- default :
- break;
- } /*switch*/
- } /*if*/
- break;
-
- case WM_CLOSE :
- /* Disconnect before terminating Windows application. */
- if (session.connected == TRUE)
- DoDisconnect(hWnd);
-
- break; /* Let this pass thru so default operation can occur. */
-
- case WM_DESTROY :
- PostQuitMessage(0);
- break;
-
- default:
- break;
- } /*switch*/
-
- /* Performs default operation. */
- return( DefWindowProc(hWnd, message, wParam, lParam) );
-
- } /*SampleWndProc*/
-
- /*
- *LogonDlg
- */
- BOOL FAR PASCAL LogonDlg(hDlg, message, wParam, lParam)
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
-
- switch (message) {
-
- case WM_COMMAND :
-
- switch (wParam) {
-
- case ID_LOGON_OK :
- GetDlgItemText(hDlg, ID_LOGON_USERID,
- (LPSTR)vc_userid.arr, MAX_USERID);
- vc_userid.len = strlen((LPSTR)vc_userid.arr);
- GetDlgItemText(hDlg, ID_LOGON_PASSWORD,
- (LPSTR)vc_password.arr, MAX_PASSWORD);
- vc_password.len = strlen((LPSTR)vc_password.arr);
- GetDlgItemText(hDlg, ID_LOGON_CONNECT,
- (LPSTR)vc_connect.arr, MAX_CONNECT);
- vc_connect.len = strlen((LPSTR)vc_connect.arr);
- EndDialog(hDlg, 1);
- return( TRUE );
-
- case ID_LOGON_CANCEL :
- EndDialog(hDlg, 0);
- return( TRUE );
-
- default :
- break;
- } /*switch*/
-
- break;
-
- case WM_INITDIALOG :
- return(TRUE);
-
- default :
- return(FALSE);
- } /*switch*/
-
- return(FALSE);
-
- } /*LogonDlg*/
-
- /*
- *DoLogon
- */
- int DoLogon(hInst, hWnd)
- HANDLE hInst;
- HWND hWnd;
- {
- FARPROC lpprocLogonDlg;
-
- if (session.connected == TRUE)
- return( TRUE );
-
- lpprocLogonDlg = MakeProcInstance(LogonDlg, hInst);
-
- while (session.connected == FALSE) {
-
- /* Give the Logon Dialog Box -- control passes to LogonDlg(). */
- if (DialogBox(hInst, MAKEINTRESOURCE( LOGONBOX ), hWnd,
- lpprocLogonDlg) == 0)
- break;
-
- /* Pro*C CONNECT statement - one of several possible forms. */
- EXEC SQL CONNECT :vc_userid IDENTIFIED BY :vc_password
- USING :vc_connect;
-
- /* Process the results of the CONNECT statement. */
- if (ProcessOracleErrorCode(hWnd) == FALSE) {
- if (MessageBox(hWnd, "Login to ORACLE",
- "ORACLE", MB_RETRYCANCEL) != IDRETRY)
- break;
- } /*if*/
- else {
- MessageBox(hWnd, "Logon Successful", "ORACLE", MB_OK);
- session.connected = TRUE;
- } /*else*/
-
- } /*while*/
-
- FreeProcInstance(lpprocLogonDlg);
-
- return( session.connected );
-
- } /*DoLogon*/
-
- /*
- *DoDisconnect
- */
- int DoDisconnect(hWnd)
- HWND hWnd;
- {
-
- if (session.connected == FALSE)
- return(TRUE);
-
- if (session.opened == TRUE) {
- EXEC SQL CLOSE emp_cursor;
- session.opened = FALSE;
- } /*if*/
-
- /* Commits the current transaction and releases the current connection.*/
- EXEC SQL COMMIT WORK RELEASE;
-
- /* Process the results of the COMMIT statement. */
- if (ProcessOracleErrorCode(hWnd) == TRUE) {
- MessageBox(hWnd, "Disconnect Successful", "ORACLE", MB_OK);
- session.connected = FALSE;
- } /*else*/
-
- return((session.connected == FALSE) ? TRUE : FALSE);
-
- } /*DoDisconnect*/