qt调用oracle存储过程,qt调用oracle存储过程,该怎么处理(3)

当前位置:我的异常网» QT开发 » qt调用oracle存储过程,该怎么处理

qt调用oracle存储过程,该怎么处理(3)

www.myexceptions.net  网友分享于:2013-03-27  浏览:221次

/*

* Call the Store Procedure which executes the Result Sets

*/

strcpy( (char *) pSqlStmt, "{CALL ODBCRefCur.EmpCurs(?)}");

rc = SQLExecDirect(hStmt, pSqlStmt, strlen((char *)pSqlStmt));

if (rc != SQL_SUCCESS)

{

DisplayError(SQL_HANDLE_STMT, hStmt, "SQLExecDirect");

}

/*

* Bind the Data

*/

rc = SQLBindCol( hStmt,1,SQL_C_CHAR,Data,sizeof(Data),&DataLen);

if (rc != SQL_SUCCESS)

{

DisplayError(SQL_HANDLE_STMT, hStmt, "SQLBindCol");

}

/*

* Get the data for Result Set 1

*/

printf( "\nEmployee Names\n\n");

while ( rc == SQL_SUCCESS )

{

rc = SQLFetch( hStmt );

if ( rc == SQL_SUCCESS )

{

printf("%s\n", Data);

}

else

{

if (rc != SQL_NO_DATA)

{

DisplayError(SQL_HANDLE_STMT, hStmt, "SQLFetch");

}

}

}

printf( "\nFirst Result Set - Hit Return to Continue\n");

charptr = gets ((char *)error);

/*

* Get the Next Result Set

*/

rc = SQLMoreResults( hStmt );

if (rc != SQL_SUCCESS)

{

DisplayError(SQL_HANDLE_STMT, hStmt, "SQLMoreResults");

}

/*

* Get the data for Result Set 2

*/

printf( "\nManagers\n\n");

while ( rc == SQL_SUCCESS )

{

rc = SQLFetch( hStmt );

if ( rc == SQL_SUCCESS )

{

printf("%s\n", Data);

}

else

{

if (rc != SQL_NO_DATA)

{

DisplayError(SQL_HANDLE_STMT, hStmt, "SQLFetch");

}

}

}

printf( "\nSecond Result Set - Hit Return to Continue\n");

charptr = gets ((char *)error);

/*

* Should Be No More Results Sets

*/

rc = SQLMoreResults( hStmt );

if (rc != SQL_NO_DATA)

{

DisplayError(SQL_HANDLE_STMT, hStmt, "SQLMoreResults");

}

/*

* Drop the Package

*/

strcpy( (char *) pSqlStmt, "DROP PACKAGE ODBCRefCur");

rc = SQLExecDirect(hStmt, pSqlStmt, strlen((char *)pSqlStmt));

/*

* Free handles close connections to the database

*/

SQLFreeHandle( SQL_HANDLE_STMT, hStmt );

SQLDisconnect( hDbc );

SQLFreeHandle( SQL_HANDLE_DBC, hDbc );

SQLFreeHandle( SQL_HANDLE_ENV, hEnv );

printf( "\nAll Done - Hit Return to Exit\n");

charptr = gets ((char *)error);

return(0);

}

/*

* Display Error Messages

*/

void DisplayError( SWORD HandleType, SQLHANDLE hHandle, char *Module )

{

SQLCHAR MessageText[255];

SQLCHAR SQLState[80];

SQLRETURN rc=SQL_SUCCESS;

long NativeError;

SWORD RetLen;

SQLCHAR error[25];

char *charptr;

rc =

SQLGetDiagRec(HandleType,hHandle,1,SQLState,&NativeError,MessageText,255,&RetLen);

printf( "Failure Calling %s\n", Module );

if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)

{

printf( "\t\t\t State: %s\n", SQLState);

printf( "\t\t\t Native Error: %d\n", NativeError );

printf( "\t\t\t Error Message: %s\n", MessageText );

}

printf( "\nHit Return to Exit\n");

charptr = gets ((char *)error);

exit(1);

}

我的异常网推荐解决方案:oracle存储过程,http://www.myexceptions.net/oracle-develop/177537.html

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值