Subject: sorry..

From: [email-masked] (Praveen Mamnani)
Date: Fri, 14 Oct 1994 17:27:30 +0700

I am sorry, by mistake the last message was sent in a wrong format.
The following is my original message..

I had some embedded SQL programs that I was converting to PQL,
 
In SQL one can do a SELECT <field name>. In PQL one can retrieve a
field in a similar manner :
 
retrieve (result = EMP.salary)
      where EMP.name = "Bill" \g
 
But when using libpq, executing such simpler queries is not easy.
One has to get the instance in a portal buffer then apply some more
functions (such as PQnfields(), PQgetvalue(), etc.) to get to that
particular field (EMP.salary), for that particular employer "Bill".
 
So every time when I have to retrieve a specific field in a class, I
have to go through this process, instead of just specifying the field
name and the "where" condition (as done in monitor).
 
        In the programs that I am converting I have many-many retrieve
statements, and for each retrieve, I will have to go through all this 
process for each different field in a different class. Is there
another way or an easier way to do such retrieve statments when using libpq?
 
your help would be greatly appriciated.
 
Praveen.

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]"

   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================

---

From: [email-masked]
Date: Sat, 15 Oct 1994 17:54:14 -0400 (EDT)

Excerpts from internet.postgres: 14-Oct-94 sorry.. Praveen
[email-masked]. (1599) 

> But when using libpq, executing such simpler queries is not easy. One
> has to get the instance in a portal buffer then apply some more

I think you are confused.  The query is executed through libpq just the
same as it is in the monitor.  The only difference is that the monitor
has some additional code that prints the results to stdout.  The
PQnfields() function is only there for your convenience in case you do
not know how many fields the query will return.  PQgetvalue() is there
so that you can get the value of each field in each tuple.  

In your example query, assuming that there is only one tuple which
matches your where condition,  the only thing that should be in the
portal is the single field "result" with the single tuple containing the
value of the salary for Bill. 

Excerpts from internet.postgres: 14-Oct-94 sorry.. Praveen
[email-masked]. (1599) 

> process for each different field in a different class. Is there another
> way or an easier way to do such retrieve statments when using libpq? 

In embedded SQL, you still have to go through a similar, although
somewhat different, process.  Normally, in embedded SQL, you execute a
query and then ask the interface how much memory is required to store
each tuple returned.  Then, you allocate the memory required for one (or
all) of the tuples and use a cursor to fetch the data into the allocated
memory.  

If you are accustomed to the embedded SQL interface, it may take a
little while to get used to libpq but I think you will find that there
isn't that much difference.  The major difference is that most (if not
all) embedded SQL interfaces provide a pre-proccessor which translates
your embedded SQL calls into the appropriate function calls for you.  In
other words, the raw C function calls are hidden from the user. 

Cheers, 
Robert