如何在pro / c客户端设置连接超时?

时间:2014-11-23 16:03:40

标签: c linux oracle timeout oracle-pro-c

我正在linux下编写一个c程序来连接oracle DB并使用oracle pro / c执行存储过程。 我的问题是我想要给这个程序留出一些时间,然后让我控制回来,让我们说出一个TIME_OUT错误(最好这个错误会从pro / c返回),那怎么可能呢?以编程方式或使用precombiler选项完成??

我的.pc文件将包含类似

的内容
bool connectToDb() {
/*variables declaration and assigning*/
EXEC SQL CONNECT :local_username IDENTIFIED BY :local_password USING :local_connectionString; // to connect to DB
/*error handling*/
}

我打电话给一个睡眠时间为30秒的测试程序。我想超时,让我们说5秒后5秒我想要一个错误(ORA错误)返回指示超时

bool callProcedure() {
/*variables declaration and assigning*/
EXEC SQL CALL  SLEEP_TEST(); //this line that I don't want to be blocked
/*errors handling*/
}

注意:我使用

处理所有错误
EXEC SQL WHENEVER SQLERROR GOTO SQLError;
/*my sql logic*/
goto EndOf_function;
SQLError:
/*Error handling portion that I want to catch the timeout*/
EndOf_function:;

任何建议??

0 个答案:

没有答案