Re: core dump using Pro*C on CONNECT

From: thumor <member34030_at_dbforums.com>
Date: 25 Jul 2003 12:28:45 GMT
Message-ID: <3151222.1059136482_at_dbforums.com>


Originally posted by Andy Finkenstadt
> In thumor writes:
> >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');
>
> Those last strcat's are not needed as strcpy already copies in the
> null terminating byte. This has nothing to do with the
> problem, though.
>
> >EXEC SQL CONNECT :Username IDENTIFIED BY :Userpass AT
> DB_NAME
> >USING :DBname;
>
>
> > if (sqlca.sqlcode != 0)
> > {
> > sprintf(Log_Msg, "Error %d (%s) Connecting
> Database
> > ",sqlca.sqlcode,sqlca.sqlerrm);
> > Log_Message(Waste_Log, "pods_init", FATAL,
> Log_Msg);
> > }
> > else
> > {
> > sprintf(Log_Msg, "Connection to Database
> Successful");
> > Log_Message(Waste_Log, "pods_init", INFORM,
> Log_Msg);
> > };
>
> What are the definitions of DBname, Username and Userpass? If they
> are VARCHARs declared inside a DECLARE SECTION, then you should be
> using:
>
> EXEC SQL BEGIN DECLARE SECTION;
> VARCHAR Username[32];
> VARCHAR Userpass[32];
> VARCHAR DBname[32];
> EXEC SQL END DECLARE SECTION;
>
> strncpy( Username.arr, user_id, sizeof(Username.arr));
> Username.len = strlen(user_id);
>
> strncpy( Userpass.arr, user_pw, sizeof(Userpass.arr));
> Userpass.len = strlen(user_pw);
>
> strncpy( DBname.arr, db_name, sizeof(DBname.arr));
> DBname.len = strlen(db_name);
>
> Andy
> --
> Andrew Finkenstadt (http://www.finkenstadt.com/andy/"]http://ww-
> w.finkenstadt.com/andy/[/url])

The variables are declared as char.
[Quoted] [Quoted] Is there any specific reason to use varchar? I tried that already and did not work either. The core dump occurs on CONNECT. I never get to the if (sqlca...) else; statments.

--
Posted via http://dbforums.com
Received on Fri Jul 25 2003 - 14:28:45 CEST

Original text of this message