how to set connection timeout in pro/c client side?

1k views Asked by At

I am writing a c program under linux to connect to oracle DB and execute a stored procedure using oracle pro/c. My problem is that I want to make a time out for calling this procedure after which I get control back with let's say a TIME_OUT error (preferably this error would be returned from the pro/c), so how can it be done either programatically or with precombiler option??

my .pc file would contain something like

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

and I call a test procedure that sleeps for say 30 sec. and I would like to make timeout for it lets say 5 sec after those 5 sec I want an error (ORA error) to return indicating timeout

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

Note: I handle all errors using

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:;

any suggestions??

0

There are 0 answers