# How to call stored procedure on iodbc

**URL:** <https://www.ruby-forum.com/t/how-to-call-stored-procedure-on-iodbc/92349>\
**Category:** Rails\
**Created:** [April 18, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/how-to-call-stored-procedure-on-iodbc/92349 "2007-04-18T16:40:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac91a4/32.png) [@vikas](https://www.ruby-forum.com/u/vikas)\
**Post date:** [April 18, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/how-to-call-stored-procedure-on-iodbc/92349/1 "2007-04-18T16:40:50Z")

</div>

Hi all,  
I am getting a problem in calling Stored Procedure from C++  
application on macintosh using OpenLink.

Exact scenario is that my stored procedure takes 6 parameters out of  
which 1 parameter is out parameter and other 5 are input parameters.

So it uses 5 IN parameters as values for inserting a row in database  
and returns its max id as out parameter.

Code Snippet is given below :–

```
SWORD returnCode = 0;
SDWORD bindReturnCode = 0;
RETCODE returnVal;
char sqlString[500];

memset(sqlString,0,sizeof(sqlString));
HSTMT hstmt = ptrDB->GetHSTMT();
returnVal = SQLAllocStmt(ptrDB->GetHDBC(), &hstmt);

if (returnVal == SQL_SUCCESS)
{
    returnVal = SQLBindParameter(hstmt, 1, SQL_PARAM_OUTPUT,

```

SQL\_C\_SLONG, SQL\_INTEGER,  
0,0, &returnCode,0, &bindReturnCode);

```
    //strcpy(sqlString,"{call PI_ShBlobData (?, 0, 0, 0,

```

EMPTY\_BLOB(), null)}");  
returnVal = SQLExecDirectA(hstmt, (UCHAR\*)sqlString,  
SQL\_NTS);

```
refPk = returnCode;
bRetVal = true;
ptrDB->CommitTrans();
}

```

SQLFreeStmt(hstmt, SQL\_DROP);

Thanks for help in advance.

---

<div class="post-metadata">

**Author:** ![vikas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac91a4/32.png) [@vikas](https://www.ruby-forum.com/u/vikas)\
**Post date:** [April 24, 2007, 12:19pm UTC](https://www.ruby-forum.com/t/how-to-call-stored-procedure-on-iodbc/92349/2 "2007-04-24T12:19:07Z")

</div>

Got the solution!!!

Yipee!!!
