Does ecpg precompile C++ programs with embedded SQL, or does it not? - Redhat

This is a discussion on Does ecpg precompile C++ programs with embedded SQL, or does it not? - Redhat ; I am about to upgrade from RHEL3 to RHEL5 and they seem to have postgresql (8.1.9 so far) as a database management system as one of the possibilities. I currently run IBM DB2 and have a bunch of C++ programs ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Does ecpg precompile C++ programs with embedded SQL, or does it not?

  1. Does ecpg precompile C++ programs with embedded SQL, or does it not?

    I am about to upgrade from RHEL3 to RHEL5 and they seem to have postgresql
    (8.1.9 so far) as a database management system as one of the possibilities.

    I currently run IBM DB2 and have a bunch of C++ programs with embedded SQL.
    I cannot find good documentation on ecpg. They seem to imply it does C++ as
    well as C, but elsewhere, I see that it is not fully implimented.

    So does it work for the most likely C++ programs, or not? If not, what do
    other people do? IBM have had a precompiler for embedded SQL since before
    2000, so it is time that postgreSQL does it to, IMAO.

    --
    .~. Jean-David Beyer Registered Linux User 85642.
    /V\ PGP-Key: 9A2FC99A Registered Machine 241939.
    /( )\ Shrewsbury, New Jersey http://counter.li.org
    ^^-^^ 23:05:01 up 6:40, 3 users, load average: 4.32, 4.23, 4.19

  2. Re: Does ecpg precompile C++ programs with embedded SQL, or does it not?

    On Thu, 21 Jun 2007 03:11:15 +0000, Jean-David Beyer wrote:

    > I am about to upgrade from RHEL3 to RHEL5 and they seem to have
    > postgresql (8.1.9 so far) as a database management system as one of the
    > possibilities.
    >
    > I currently run IBM DB2 and have a bunch of C++ programs with embedded
    > SQL. I cannot find good documentation on ecpg. They seem to imply it
    > does C++ as well as C, but elsewhere, I see that it is not fully
    > implimented.
    >
    > So does it work for the most likely C++ programs, or not? If not, what
    > do other people do? IBM have had a precompiler for embedded SQL since
    > before 2000, so it is time that postgreSQL does it to, IMAO.


    Must be out of my depth... how and for that matter why do you pre-compile
    an interpreted language?

  3. Re: Does ecpg precompile C++ programs with embedded SQL, or doesit not?

    Ivan Marsh wrote:
    > On Thu, 21 Jun 2007 03:11:15 +0000, Jean-David Beyer wrote:
    >
    >> I am about to upgrade from RHEL3 to RHEL5 and they seem to have
    >> postgresql (8.1.9 so far) as a database management system as one of the
    >> possibilities.
    >>
    >> I currently run IBM DB2 and have a bunch of C++ programs with embedded
    >> SQL. I cannot find good documentation on ecpg. They seem to imply it
    >> does C++ as well as C, but elsewhere, I see that it is not fully
    >> implimented.
    >>
    >> So does it work for the most likely C++ programs, or not? If not, what
    >> do other people do? IBM have had a precompiler for embedded SQL since
    >> before 2000, so it is time that postgreSQL does it to, IMAO.

    >
    > Must be out of my depth... how and for that matter why do you pre-compile
    > an interpreted language?


    I guess it is beyond your depth, unless we completely misunderstand each other.

    Embedded SQL is normally used in a normal "higher level" language, like C,
    or C++, so that the non-procedural SQL statements generate the proper calls
    to the (in this case) postgresql API run-time library to get the stuff done.
    While it is theoretically possible to call the run-time library directly, it
    harms portability and clarity compared with just writing the SQL statements
    in the C or C++ program, bracketed with a EXEC SQL and a semicolon. Once
    such a program is written, all you have to do is precompile it with a
    suitable preprocessor (e.g., IBM's db2 pre-compiler or postgresql's ecpg
    program) that converts a file in the language in question with embedded SQL
    to a similar program without the SQL. You then run that program through the
    regular compiler to get a runnable program.

    I suppose SQL can be interpreted for a simple user-interface that just looks
    up stuff, and perhaps adds, updates, or deletes a few records at a time. But
    for a major database application you would not want these things interpreted
    because the efficiency is far too low. When you write a program with
    embedded SQL, this is usually pre-compiled to a C or C++ (or Fortran or
    whatever language you would normally use) first. In addition to converting
    the SQL to function calls, where possible the dbms arranges that the queries
    are processed in an optimum fashion (choosing whether to use indices or
    sequential search, picking the order of searches where joins are involved,
    and so on) that the average programmer would not have the resources to
    decide by himself.

    --
    .~. Jean-David Beyer Registered Linux User 85642.
    /V\ PGP-Key: 9A2FC99A Registered Machine 241939.
    /( )\ Shrewsbury, New Jersey http://counter.li.org
    ^^-^^ 14:40:01 up 22:15, 3 users, load average: 4.27, 4.18, 4.07

+ Reply to Thread