Re: core dump using Pro*C on CONNECT

From: thumor <member34030_at_dbforums.com>
Date: Wed, 30 Jul 2003 14:42:38 +0000
Message-ID: <3165816.1059576158_at_dbforums.com>


Originally posted by Volker Hetzer
> "thumor" schrieb im Newsbeitrag
> news:3157120.1059407316_at_dbforums.com"]news:3157120.1059407316_at_d-
> bforums.com[/url]...
> > Originally posted by Volker Hetzer
> > > "thumor" schrieb im Newsbeitrag
> > > news:3148847.1059070191_at_dbforums.com"]news:3148847.1059-
> 070191_at_dbforums.com[/url]"]news:3148847.1059070191_at_d-"]news-
> :3148847.1059070191_at_d-[/url]
> > > bforums.com[/url]...
> > > > Line of code in my Pro*C file:
> > > >
> > > > strcpy(Username, user_id);
> > > > strcpy(Userpass, user_pw);
> > > > strcpy(DBname, db_name);
> > > > strcat(Username, '\0');
> > > > strcat(Userpass, '\0');
> > > > strcat(DBname, '\0');
> > > > EXEC SQL CONNECT :Username IDENTIFIED BY :Userpass AT
> > > DB_NAME
> > > > USING :DBname;
> > > Had the same problem on linux. Workaround:
> > > EXEC SQL CONNECT :Username_at_DBname IDENTIFIED BY :Userpass
> > >
> > > Lots of Greetings!
> > > Volker
> > Should this be like
> > EXEC SQL CONNECT :Username_at_:DBname IDENTIFIED BY :Userpass;
> > Note- The colon before DBname.
> This is my file modified from the demos directory.
> /*
> * sample1.pc
> *
> * Prompts the user for an employee number,
> * then queries the emp table for the employee's
> * name, salary and commission. Uses indicator
> * variables (in an indicator struct) to determine
> * if the commission is NULL.
> *
> */
> #include
> #include
> #include
> #include
> #include
> #include
> /* Define constants for VARCHAR lengths. */
> #define UNAME_LEN 20
> #define PWD_LEN 40
> #define DB_LEN 40
> /* Declare variables. No declare section is
> needed if MODE=ORACLE. */
> VARCHAR username[UNAME_LEN]; /* VARCHAR is an Oracle-supplied
> struct */
> varchar password[PWD_LEN]; /* varchar can be in lower case also. */
> varchar db[DB_LEN]; /* varchar can be in lower case also. */

>

> /* Declare error handling function. */
> void sql_error(msg)
> char *msg;
> {
> char err_msg[128];
> size_t buf_len, msg_len;
> EXEC SQL WHENEVER SQLERROR CONTINUE;
> printf("\n%s\n", msg);
> buf_len = sizeof (err_msg);
> sqlglm(err_msg, &buf_len, &msg_len);
> printf("%.*s\n", msg_len, err_msg);
> EXEC SQL ROLLBACK RELEASE;
> exit(EXIT_FAILURE);
> }
> int main(int argc,char*argv[])
> {
> strncpy((char *) username.arr, "SPIELPLATZ_at_ecadtst", UNAME_LEN);
> username.len = (unsigned short) strlen((char *) username.arr);
> strncpy((char *) password.arr, "SPIELPLATZ", PWD_LEN);
> password.len = (unsigned short) strlen((char *) password.arr);
> strncpy((char *) db.arr, "ecadtst", DB_LEN);
> db.len = (unsigned short) strlen((char *) db.arr);
> EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");
> EXEC SQL CONNECT :username IDENTIFIED BY :password ;
> printf("\nConnected to ORACLE as user: %s\n", username.arr);
> exit(EXIT_SUCCESS);
> }

[Quoted] Thanks for the code, but there is basically no difference in the way I attempt to connect.

But, ALL of you, here is the twist I found.

If I declare ORACLE_SID=db_name (correct db name) and use

 EXEC SQL CONNECT :Username IDENTIFIED BY :Userpass;

It does not error out.

Also,
If I give the incorrect Username, Password - I still go past the CONNECT statement, which then gives me ORA-ERR 1017.

[Quoted] What do you say to that??

--
Posted via http://dbforums.com
Received on Wed Jul 30 2003 - 16:42:38 CEST

Original text of this message