Pro*C++ HELP! 
Author Message
 Pro*C++ HELP!

First off... TO all the idiots that "designed" Pro*C/C++...
   You're idiots.

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.

What the hell was wrong with simply implenting a class "SQLServer" or
other such standard C++ constructs and then forgetting about your
stupid Pro*C/C++ pre-pre-processor????

I guess it would too easy to have users just use:

#include <sqlstuff.h>

and then allowing the user to use normal ANSI C++ stuff???????
And what the HELL is with all the libraries I have to include on the
compiling command line. (Not that I've gotten that far yet.

Ok now.  Hopefully somebody has gotten a C++ program to work using
"Pro"*C/C++ and can help me out...

All I want right now is to make a class wrapper so that I can easily
use this stuff in the future.

So I did this...

File: oracle_wrapper.h
-----------------------------------------------------

extern unsigned char SQLerror[1024];

class SqlServer
{
 private:
  int connected;
 public:
  SqlServer(void) : connected(0) {};
  int Connect(char *username, char *password);
  int Disconnect(void);
  int Commit(void);
  int Init(void);
  int Execute(const char *sql_statement);
  int Prepare(const char *sql_statement);
  int Fields(char *buffer, int max);
  int Ignore(void);
  int Fetch(char *buffer, int max);
  int Done(void);
  int Quit(void);

Quote:
};

and then I made a simple oracle_wrapper.C file to provide me with the
methods... (Of which I will only show you the first method "Connect".

File: oracle_wrapper.pc
-----------------------------------------------------------
unsigned char memory[MEMSIZE];
unsigned char SQLerror[1024];

EXEC ORACLE OPTION (ORACA=NO);

EXEC ORACLE OPTION (RELEASE_CURSOR=YES);

EXEC SQL INCLUDE sqlca;
EXEC SQL INCLUDE sqlda;
EXEC SQL INCLUDE oraca;

extern SQLDA *sqlald();
extern void sqlnul();

SQLDA *bind_descriptor;      // descriptor area for bind variables
SQLDA *select_descriptor;    // descriptor area for select list items

#include "oracle_wrapper.h"

/*
  establish an RDBMS connection
*/

int SqlServer::Connect(char *username, char *password)
{
  EXEC SQL CONNECT :username IDENTIFIED BY :password;
  if (sqlca.sqlcode < 0)
      return -1;

  return 1;

Quote:
}

When I run "proc code=cpp oracle_wrapper.pc I get this...

     Pro*C/C++: Release 8.0.5.0.0 - Production on Thu Dec 17 16:50:59 1998

     (c) Copyright 1998 Oracle Corporation.  All rights reserved.

     System default option values taken from:
              /usr/lib/Oracle/8.0.5/precomp/admin/pcscfg.cfg

     Semantic error at line 26, column 21, file oracle_wrapper.pc:
       EXEC SQL CONNECT :username IDENTIFIED BY :password;
     ....................1
     PCC-S-02322, found undefined identifier

So it seems a bit like this Pro*C/C++ preprocessor doesn't really know
C++ at all cause "username" is declared and defined on the very previous
line as an argument to the function.

If Pro*C/C++ doesn't allow argument definitions then its a pretty{*filter*}
poor C++ "language".

Sorry for the tone of this message but I've been working on this for days
now and haven't gotten anywhere with it and the documentation is so
cryptic as to be completely useless.

Even the cppdemo included don't compile.  They preprocess ok but thats
because that only have global variables and we all know from school that
global variables are not good.

Please Help me if you can. Thanks,

J E F F   W I E G L E Y,  Ph.D.
Systems Analyst
___________________________________________________
USWeb/CKS Corporation       http://www.***.com/
8522 National Blvd, Suite 101
Culver City, CA 90232
ph  310 815 1177 x 216             fax 310 815 1133

USWeb - A Strategic Partner for the Information Age



Tue, 05 Jun 2001 03:00:00 GMT
 Pro*C++ HELP!

Hi,

Take a look on Oracle Call Interface (OCI). It can be easiely
wrapped in C++ classes. I use Direct Oracle Access (DOA) which
are wrapper classes of OCI in Object Pascal (Delphi).

Andrew Protasov

Quote:
>   First off... TO all the idiots that "designed" Pro*C/C++...
>      You're idiots.

>   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.

>   What the hell was wrong with simply implenting a class "SQLServer" or
>   other such standard C++ constructs and then forgetting about your
>   stupid Pro*C/C++ pre-pre-processor????

>   I guess it would too easy to have users just use:

>   #include <sqlstuff.h>

>   and then allowing the user to use normal ANSI C++ stuff???????
>   And what the HELL is with all the libraries I have to include on the
>   compiling command line. (Not that I've gotten that far yet.

>   Ok now.  Hopefully somebody has gotten a C++ program to work using
>   "Pro"*C/C++ and can help me out...

>   All I want right now is to make a class wrapper so that I can easily
>   use this stuff in the future.

>   So I did this...

>   File: oracle_wrapper.h
>   -----------------------------------------------------

>   extern unsigned char SQLerror[1024];

>   class SqlServer
>   {
>    private:
>     int connected;
>    public:
>     SqlServer(void) : connected(0) {};
>     int Connect(char *username, char *password);
>     int Disconnect(void);
>     int Commit(void);
>     int Init(void);
>     int Execute(const char *sql_statement);
>     int Prepare(const char *sql_statement);
>     int Fields(char *buffer, int max);
>     int Ignore(void);
>     int Fetch(char *buffer, int max);
>     int Done(void);
>     int Quit(void);
>   };

>   and then I made a simple oracle_wrapper.C file to provide me with the
>   methods... (Of which I will only show you the first method "Connect".

>   File: oracle_wrapper.pc
>   -----------------------------------------------------------
>   unsigned char memory[MEMSIZE];
>   unsigned char SQLerror[1024];

>   EXEC ORACLE OPTION (ORACA=NO);

>   EXEC ORACLE OPTION (RELEASE_CURSOR=YES);

>   EXEC SQL INCLUDE sqlca;
>   EXEC SQL INCLUDE sqlda;
>   EXEC SQL INCLUDE oraca;

>   extern SQLDA *sqlald();
>   extern void sqlnul();

>   SQLDA *bind_descriptor;      // descriptor area for bind variables
>   SQLDA *select_descriptor;    // descriptor area for select list items

>   #include "oracle_wrapper.h"

>   /*
>     establish an RDBMS connection
>   */

>   int SqlServer::Connect(char *username, char *password)
>   {
>     EXEC SQL CONNECT :username IDENTIFIED BY :password;
>     if (sqlca.sqlcode < 0)
>         return -1;

>     return 1;
>   }

>   When I run "proc code=cpp oracle_wrapper.pc I get this...

>        Pro*C/C++: Release 8.0.5.0.0 - Production on Thu Dec 17 16:50:59 1998

>        (c) Copyright 1998 Oracle Corporation.  All rights reserved.

>        System default option values taken from:
>                 /usr/lib/Oracle/8.0.5/precomp/admin/pcscfg.cfg

>        Semantic error at line 26, column 21, file oracle_wrapper.pc:
>          EXEC SQL CONNECT :username IDENTIFIED BY :password;
>        ....................1
>        PCC-S-02322, found undefined identifier

>   So it seems a bit like this Pro*C/C++ preprocessor doesn't really know
>   C++ at all cause "username" is declared and defined on the very previous
>   line as an argument to the function.

>   If Pro*C/C++ doesn't allow argument definitions then its a pretty{*filter*}
>   poor C++ "language".

>   Sorry for the tone of this message but I've been working on this for days
>   now and haven't gotten anywhere with it and the documentation is so
>   cryptic as to be completely useless.

>   Even the cppdemo included don't compile.  They preprocess ok but thats
>   because that only have global variables and we all know from school that
>   global variables are not good.

>   Please Help me if you can. Thanks,

>   J E F F   W I E G L E Y,  Ph.D.
>   Systems Analyst
>   ___________________________________________________
>   USWeb/CKS Corporation       http://www.***.com/
>   8522 National Blvd, Suite 101
>   Culver City, CA 90232
>   ph  310 815 1177 x 216             fax 310 815 1133

>   USWeb - A Strategic Partner for the Information Age



Tue, 05 Jun 2001 03:00:00 GMT
 Pro*C++ HELP!
Hi Jeff,
the Oracle pre-processor is only capable of using host variables declared
using  the ORACLE EXEC BEGIN DELCARE,EXEC END DECLARE statements or the
MODE=ORACLE precompiled option in Oracle 8.x only as far as I can make out.

see Oracle web site for details,
as far as I can make out this is how you could do the connect

int SqlServer::Connect(char *username, char *password)
{

 VARCHAR    ora_username[UNAME_LEN];
 VARCHAR    ora_passwordpPWD_LEN];

 // setup the external variables for the oracle call
 strcpy(ora_username,username);
 strcpy(ora_password,password);

 // do the oracle call
 EXEC SQL CONNECT :ora_username  \
                                           IDENTIFIED BY  :ora_password;

 if (sqlca.sqlcode < 0)
      return -1;

  return 1;

Quote:
}

I am no expert but have had to use Pro C/C++ and Pro COBOL before.

I haven't tested it but as far as the documentation is concerned it should
work.

I do agree that the Oracle Call Interface is probably easier to use, when
trying to build C++ classes.

Quote:

>First off... TO all the idiots that "designed" Pro*C/C++...
>   You're idiots.

>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.

>What the hell was wrong with simply implenting a class "SQLServer" or
>other such standard C++ constructs and then forgetting about your
>stupid Pro*C/C++ pre-pre-processor????

>I guess it would too easy to have users just use:

>#include <sqlstuff.h>

>and then allowing the user to use normal ANSI C++ stuff???????
>And what the HELL is with all the libraries I have to include on the
>compiling command line. (Not that I've gotten that far yet.

>Ok now.  Hopefully somebody has gotten a C++ program to work using
>"Pro"*C/C++ and can help me out...

>All I want right now is to make a class wrapper so that I can easily
>use this stuff in the future.

>So I did this...

>File: oracle_wrapper.h
>-----------------------------------------------------

>extern unsigned char SQLerror[1024];

>class SqlServer
>{
> private:
>  int connected;
> public:
>  SqlServer(void) : connected(0) {};
>  int Connect(char *username, char *password);
>  int Disconnect(void);
>  int Commit(void);
>  int Init(void);
>  int Execute(const char *sql_statement);
>  int Prepare(const char *sql_statement);
>  int Fields(char *buffer, int max);
>  int Ignore(void);
>  int Fetch(char *buffer, int max);
>  int Done(void);
>  int Quit(void);
>};

>and then I made a simple oracle_wrapper.C file to provide me with the
>methods... (Of which I will only show you the first method "Connect".

>File: oracle_wrapper.pc
>-----------------------------------------------------------
>unsigned char memory[MEMSIZE];
>unsigned char SQLerror[1024];

>EXEC ORACLE OPTION (ORACA=NO);

>EXEC ORACLE OPTION (RELEASE_CURSOR=YES);

>EXEC SQL INCLUDE sqlca;
>EXEC SQL INCLUDE sqlda;
>EXEC SQL INCLUDE oraca;

>extern SQLDA *sqlald();
>extern void sqlnul();

>SQLDA *bind_descriptor;      // descriptor area for bind variables
>SQLDA *select_descriptor;    // descriptor area for select list items

>#include "oracle_wrapper.h"

>/*
>  establish an RDBMS connection
>*/

>int SqlServer::Connect(char *username, char *password)
>{
>  EXEC SQL CONNECT :username IDENTIFIED BY :password;
>  if (sqlca.sqlcode < 0)
>      return -1;

>  return 1;
>}

>When I run "proc code=cpp oracle_wrapper.pc I get this...

>     Pro*C/C++: Release 8.0.5.0.0 - Production on Thu Dec 17 16:50:59 1998

>     (c) Copyright 1998 Oracle Corporation.  All rights reserved.

>     System default option values taken from:
>              /usr/lib/Oracle/8.0.5/precomp/admin/pcscfg.cfg

>     Semantic error at line 26, column 21, file oracle_wrapper.pc:
>       EXEC SQL CONNECT :username IDENTIFIED BY :password;
>     ....................1
>     PCC-S-02322, found undefined identifier

>So it seems a bit like this Pro*C/C++ preprocessor doesn't really know
>C++ at all cause "username" is declared and defined on the very previous
>line as an argument to the function.

>If Pro*C/C++ doesn't allow argument definitions then its a pretty{*filter*}
>poor C++ "language".

>Sorry for the tone of this message but I've been working on this for days
>now and haven't gotten anywhere with it and the documentation is so
>cryptic as to be completely useless.

>Even the cppdemo included don't compile.  They preprocess ok but thats
>because that only have global variables and we all know from school that
>global variables are not good.

>Please Help me if you can. Thanks,

>J E F F   W I E G L E Y,  Ph.D.
>Systems Analyst
>___________________________________________________
>USWeb/CKS Corporation       http://www.***.com/
>8522 National Blvd, Suite 101
>Culver City, CA 90232
>ph  310 815 1177 x 216             fax 310 815 1133

>USWeb - A Strategic Partner for the Information Age



Tue, 05 Jun 2001 03:00:00 GMT
 Pro*C++ HELP!
Hi Dr. Wiegley,

    First of all, I'm not working with the Oracle company and I'm just as an
ordinary Computer Consultant. I've been working with different programming
languages from Assembly language to C++ language. I don't believe that they
are idiots when it comes to programming. They have been designing this Pro*C
for several years before they release it.

    It seems like you are a newbies in Pro*C. But my suggestion is , before
you use any software languages. You must have their users manual, so that
you can use it properly.

    To answer your question, Oracle pre-processor is capable of using host
variable. try to declare first you variable before you use it .

    Try this.

int SqlServer::Connect(char *username, char *password)

  char  c_username[30], c_password[30];

{

  EXEC SQL CONNECT :c_username IDENTIFIED BY :c_password;
  if (sqlca.sqlcode < 0)
      return -1;

  return 1;

Quote:
}

the Oracle pre-processor is only capable of using host variables declared
using  the ORACLE EXEC BEGIN DELCARE,EXEC END DECLARE statements or the
MODE=ORACLE precompiled option in Oracle 8.x only as far as I can make out.
Quote:

>First off... TO all the idiots that "designed" Pro*C/C++...
>   You're idiots.

>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.

>What the hell was wrong with simply implenting a class "SQLServer" or
>other such standard C++ constructs and then forgetting about your
>stupid Pro*C/C++ pre-pre-processor????

>I guess it would too easy to have users just use:

>#include <sqlstuff.h>

>and then allowing the user to use normal ANSI C++ stuff???????
>And what the HELL is with all the libraries I have to include on the
>compiling command line. (Not that I've gotten that far yet.

>Ok now.  Hopefully somebody has gotten a C++ program to work using
>"Pro"*C/C++ and can help me out...

>All I want right now is to make a class wrapper so that I can easily
>use this stuff in the future.

>So I did this...

>File: oracle_wrapper.h
>-----------------------------------------------------

>extern unsigned char SQLerror[1024];

>class SqlServer
>{
> private:
>  int connected;
> public:
>  SqlServer(void) : connected(0) {};
>  int Connect(char *username, char *password);
>  int Disconnect(void);
>  int Commit(void);
>  int Init(void);
>  int Execute(const char *sql_statement);
>  int Prepare(const char *sql_statement);
>  int Fields(char *buffer, int max);
>  int Ignore(void);
>  int Fetch(char *buffer, int max);
>  int Done(void);
>  int Quit(void);
>};

>and then I made a simple oracle_wrapper.C file to provide me with the
>methods... (Of which I will only show you the first method "Connect".

>File: oracle_wrapper.pc
>-----------------------------------------------------------
>unsigned char memory[MEMSIZE];
>unsigned char SQLerror[1024];

>EXEC ORACLE OPTION (ORACA=NO);

>EXEC ORACLE OPTION (RELEASE_CURSOR=YES);

>EXEC SQL INCLUDE sqlca;
>EXEC SQL INCLUDE sqlda;
>EXEC SQL INCLUDE oraca;

>extern SQLDA *sqlald();
>extern void sqlnul();

>SQLDA *bind_descriptor;      // descriptor area for bind variables
>SQLDA *select_descriptor;    // descriptor area for select list items

>#include "oracle_wrapper.h"

>/*
>  establish an RDBMS connection
>*/

>int SqlServer::Connect(char *username, char *password)
>{
>  EXEC SQL CONNECT :username IDENTIFIED BY :password;
>  if (sqlca.sqlcode < 0)
>      return -1;

>  return 1;
>}

>When I run "proc code=cpp oracle_wrapper.pc I get this...

>     Pro*C/C++: Release 8.0.5.0.0 - Production on Thu Dec 17 16:50:59 1998

>     (c) Copyright 1998 Oracle Corporation.  All rights reserved.

>     System default option values taken from:
>              /usr/lib/Oracle/8.0.5/precomp/admin/pcscfg.cfg

>     Semantic error at line 26, column 21, file oracle_wrapper.pc:
>       EXEC SQL CONNECT :username IDENTIFIED BY :password;
>     ....................1
>     PCC-S-02322, found undefined identifier

>So it seems a bit like this Pro*C/C++ preprocessor doesn't really know
>C++ at all cause "username" is declared and defined on the very previous
>line as an argument to the function.

>If Pro*C/C++ doesn't allow argument definitions then its a pretty{*filter*}
>poor C++ "language".

>Sorry for the tone of this message but I've been working on this for days
>now and haven't gotten anywhere with it and the documentation is so
>cryptic as to be completely useless.

>Even the cppdemo included don't compile.  They preprocess ok but thats
>because that only have global variables and we all know from school that
>global variables are not good.

>Please Help me if you can. Thanks,

>J E F F   W I E G L E Y,  Ph.D.
>Systems Analyst
>___________________________________________________
>USWeb/CKS Corporation       http://www.***.com/
>8522 National Blvd, Suite 101
>Culver City, CA 90232
>ph  310 815 1177 x 216             fax 310 815 1133

>USWeb - A Strategic Partner for the Information Age



Thu, 07 Jun 2001 03:00:00 GMT
 Pro*C++ HELP!

Quote:
> 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);

Quote:
};

********* 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];
   EXEC SQL END DECLARE SECTION;

   if (!u_name)
      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;

Quote:
}



Fri, 08 Jun 2001 03:00:00 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. Free Pro*C++ Guide - Essential Pro*C++ (for first 100 replies )

2. Third party C++ objects for Pro*C/C++

3. Multi-threaded Pro*C/Pro*C++ applications...

4. HELP NEEDED: Pro*C/C++

5. HELP: Dynamic SQL/Pro*C++ core dumps

6. HELP NEEDED: Pro*C/C++

7. Pro*C and C++?, Help me

8. Help, Runtime contexts in Pro*c/c++

9. Installing pro*C/C++ problem!, please help!

10. C++, C++, C++, C++

11. Help: Visual C++/ Borland C++ with DBLIB....


 
Powered by phpBB® Forum Software