Oracle/C++ stored procedure call 
Author Message
 Oracle/C++ stored procedure call

I am having problems calling an Oracle stored procedure from C++ using
ODBC.  The code is below.


void CNo{*filter*}gine::SendMessage(CMessage* aMessage)
{

        // hard coded : build column array for generic
#define SIZEID 80
#define SIZEMESSAGE 1000

        SWORD  returnCode;
        SDWORD bindReturnCode;
        SDWORD bindFromId;
        SDWORD bindToId;
        SDWORD bindMessageText;
        UCHAR  bufferFromId[SIZEID];
        UCHAR  bufferToId[SIZEID];
        UCHAR  bufferMessageText[SIZEMESSAGE];
    const char *pFromId;
        const char *pToId;
        const char *pMessageText;
        RETCODE returnVal;
        char sqlString[500];
        unsigned char *test;

        memset(sqlString,0,sizeof(sqlString));

        retcode = SQLAllocStmt(hdbc, &hstmt);

        if (retcode == SQL_SUCCESS)
        {

                SQLBindParameter(hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG,
SQL_INTEGER,
                        0,0, &returnCode,0, &bindReturnCode);
                SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR,
                        SIZEID,0, bufferFromId,0, &bindFromId);
                SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR,
                        SIZEID,0, bufferToId,0, &bindToId);
                SQLBindParameter(hstmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR,
                        SIZEMESSAGE,0, bufferMessageText,0,
&bindMessageText);

                pFromId = ((LPCTSTR) aMessage->FromId());
                memset(bufferFromId,0,sizeof(bufferFromId));
                memcpy(bufferFromId,pFromId,strlen(pFromId));

                pToId = ((LPCTSTR) aMessage->ToId());
                memset(bufferToId,0,sizeof(bufferToId));
                memcpy(bufferToId,pToId,strlen(pToId));

                pMessageText = ((LPCTSTR) aMessage->MessageText());
                memset(bufferMessageText,0,sizeof(bufferMessageText));
                memcpy(bufferMessageText,pMessageText,strlen(pMessageText)
;

                strcpy(sqlString,"{?=call MESSAGE_INS(?,?,?)}");
                retcode = SQLExecDirect(hstmt, (UCHAR*) sqlString,
SQL_NTS);

        }

        SQLFreeStmt(hstmt, SQL_DROP);



Fri, 11 Dec 1998 03:00:00 GMT  
 Oracle/C++ stored procedure call

Quote:

> I am having problems calling an Oracle stored procedure from C++ using
> ODBC.  The code is below.


> void CNo{*filter*}gine::SendMessage(CMessage* aMessage)
> {

>         // hard coded : build column array for generic
> #define SIZEID 80
> #define SIZEMESSAGE 1000

>         SWORD  returnCode;
>         SDWORD bindReturnCode;
>         SDWORD bindFromId;
>         SDWORD bindToId;
>         SDWORD bindMessageText;
>         UCHAR  bufferFromId[SIZEID];
>         UCHAR  bufferToId[SIZEID];
>         UCHAR  bufferMessageText[SIZEMESSAGE];
>     const char *pFromId;
>         const char *pToId;
>         const char *pMessageText;
>         RETCODE returnVal;
>         char sqlString[500];
>         unsigned char *test;

>         memset(sqlString,0,sizeof(sqlString));

>         retcode = SQLAllocStmt(hdbc, &hstmt);

>         if (retcode == SQL_SUCCESS)
>         {

>                 SQLBindParameter(hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG,
> SQL_INTEGER,
>                         0,0, &returnCode,0, &bindReturnCode);
>                 SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
> SQL_CHAR,
>                         SIZEID,0, bufferFromId,0, &bindFromId);
>                 SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR,
> SQL_CHAR,
>                         SIZEID,0, bufferToId,0, &bindToId);
>                 SQLBindParameter(hstmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR,
> SQL_CHAR,
>                         SIZEMESSAGE,0, bufferMessageText,0,
> &bindMessageText);

>                 pFromId = ((LPCTSTR) aMessage->FromId());
>                 memset(bufferFromId,0,sizeof(bufferFromId));
>                 memcpy(bufferFromId,pFromId,strlen(pFromId));

>                 pToId = ((LPCTSTR) aMessage->ToId());
>                 memset(bufferToId,0,sizeof(bufferToId));
>                 memcpy(bufferToId,pToId,strlen(pToId));

>                 pMessageText = ((LPCTSTR) aMessage->MessageText());
>                 memset(bufferMessageText,0,sizeof(bufferMessageText));
>                 memcpy(bufferMessageText,pMessageText,strlen(pMessageText)
> ;

>                 strcpy(sqlString,"{?=call MESSAGE_INS(?,?,?)}");
>                 retcode = SQLExecDirect(hstmt, (UCHAR*) sqlString,
> SQL_NTS);

>         }

>         SQLFreeStmt(hstmt, SQL_DROP);

I think it ODBC drivers' problems: many drivers doen't support
stored procedure calls or output parameters. Try Intersolve driver:
and in ODBC Test look output result after SQLNativesql after
{call blabla}


Mon, 14 Dec 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calling Oracle stored procedure from VC++

2. How to call a stored procedure of Oracle in MFC

3. Problems calling Oracle stored procedures from VC++ over ADO(OLEDB)

4. Calling Oracle stored procedures using MFC's classes

5. C++ and MFC for Extended Stored Procedure(ORACLE)

6. Calling Stored Procedures Using ADO2.5 in Visual C++ 6

7. ADO Stored Procedure Calls with C++

8. how to pass array to oracle stored procedure?

9. execv function fails when used as an Oracle external stored procedure

10. Help with VC++ to Oracle using Stored Procedures

11. ATL - >Oracle - >Stored Procedure

12. ATL - >Oracle - >Stored Procedure

 

 
Powered by phpBB® Forum Software