Re: Capturing Ctrl-C in PRO*C program
Date: Thu, 19 May 1994 14:15:11 GMT
Message-ID: <ccahdm.52.01815AA9_at_beluga.upe.ac.za>
In article <Cpyqns.Eqs_at_ncrcae.ColumbiaSC.NCR.COM> Rich Cannon <Rich.Cannon_at_ColumbiaSC.NCR.COM> writes:
>A friend of mine is using C and PRO*C as a user interface to an Oracle 7
>database. They are trying to capture a ctrl-C during an exec SQL on a long
>query so that they can break out of the query. Is there anyway to capture this
>Ctrl-C while the query is running or otherwise get out of the query?
As far as I know Oracle is aware of the break key and if you have a WHENEVER SQLERROR clause it will cause a ORA error for user requested cancel, at least on a Oracle process running on the host (it might not be the case on the client side of a client server based database).
If this doesn't work for you then you could try setting up a signal handler as follows :
void ctrlchandler( int sig )
{ signal( SIGINT, SIG_IGN );
...
...
EXEC SQL ROLLBACK;
exit(-1);
}
void main( void )
{...
...
if( signal( SIGINT, ctrlchandler ) == SIG_ERR )
{ fprintf( stderr, "Couldn't set SIGINT\n" );
abort();
}
...
...
}
This should work in UNIX, but I have'nt tried it in DOS.
Donald Munro (ccahdm_at_beluga.upe.ac.za) Computing Centre, University of Port Elizabeth Received on Thu May 19 1994 - 16:15:11 CEST