Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Pro*C++ HELP!
> Pro*C/C++ is *easiliest* the most non standard, non portable, sloppy
> non-intuitive, non-functional "language" I have ever had the
> dissapointment to be forced to use .........
I hope this helps
// header file (hpp)
class OracleOperation
{
public: static int LogIn(const char *username, const char *password, const char *server_string = 0L); static int LogOut(void); static int ExecuteSql(char *in, int *count = 0L, int commit = 1); static int GetNumber(char *sqlStmt, double &number); static int Commit(void); static int Rollback(void); static void ErrorHandler(struct sqlca sqlca);
};
********* Source file (cpp)
int OracleOperation::LogIn(const char *u_name, const char *p_word, const char
*s_string)
{
EXEC SQL BEGIN DECLARE SECTION;
const int UNAME_LEN = 40; char username[UNAME_LEN]; char password[UNAME_LEN]; char dbstring[UNAME_LEN];
return ORA_FAIL;
strcpy(username, u_name);
if (p_word)
strcpy(password, p_word);
else
password[0] = '\0';
if (s_string)
strcpy(dbstring, s_string);
else
dbstring[0] = '\0';
EXEC SQL WHENEVER SQLERROR GOTO log_in_error;
EXEC SQL CONNECT :username IDENTIFIED BY :password USING
:dbstring;
return ORA_SUCCESS;
log_in_error:
ErrorHandler(sqlca); return ORA_ERROR;