Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Using Pro*C in a Windows DLL
On 24 Feb 2005 11:32:23 -0800, "Keith Bloom" <akbloom_at_toad.net> wrote:
>I don't quite understand. The connection function looks like this
>(eliminating irrelevancies):
>
> if (strlen(dbname) == 0) {
> EXEC SQL WHENEVER SQLERROR DO sql_error("login");
> EXEC SQL CONNECT :username IDENTIFIED BY :password;
> } else {
> EXEC SQL WHENEVER SQLERROR DO sql_error("login");
> EXEC SQL DECLARE POLREPO DATABASE;
> EXEC SQL CONNECT :username IDENTIFIED BY :password AT POLREPO
> USING :dbname;
> }
> if (strcmp(SQLSTATE, SQL_SUCCESS) != 0) {
> strcpy (*p_errcode, SQLSTATE);
> return -1;
> }
> return 0;
>
>Is there some other kind of connect statement I need to include?
No. I was assuming you expected not to have to include a connect
function.
The ora-1012 is a clear sign you are not connected. This may happen of
course when you have no connect at all, or when your connect fails.
So your connect must fail, and your program doesn't deal with ith
properly.
I'm not sure why you don't test on the SQLCA directly instead of
sqlstate.
Obviously if no database name is specified, the registry variable
LOCAL must have been set to the default database, or you should error
out.
-- Sybrand Bakker, Senior Oracle DBAReceived on Thu Feb 24 2005 - 15:44:02 CST