Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.9/8.6.3) with SMTP id OAA21511 for postgres-redist; Sat, 15 Oct 1994 14:54:48 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199410152154.OAA21511@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from EIGER.EDRC.CMU.EDU (EIGER.EDRC.CMU.EDU [128.2.214.41]) by nobozo.CS.Berkeley.EDU (8.6.9/8.6.3) with SMTP id OAA21501 for <postgres@postgres.berkeley.edu>; Sat, 15 Oct 1994 14:54:46 -0700
Received: from Messages.8.5.N.CUILIB.3.45.SNAP.NOT.LINKED.EIGER.EDRC.CMU.EDU.pmax.mach
          via MS.5.6.EIGER.EDRC.CMU.EDU.pmax_mach;
          Sat, 15 Oct 1994 17:54:14 -0400 (EDT)
Message-ID: <gic4y6m00hMdE1MZEU@cs.cmu.edu>
Date: Sat, 15 Oct 1994 17:54:14 -0400 (EDT)
From: Robert.Patrick@cs.cmu.edu
To: postgres@postgres.Berkeley.EDU, Praveen Mamnani <pmamnani@cs.nmsu.edu>
Subject: Re: sorry..
CC: pmamnani@nmsu.EDU
In-Reply-To: <9410142327.AA01058@chaperito>
References: <9410142327.AA01058@chaperito>
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Sat, 15 Oct 94 14:54:48 -0700
Resent-XMts: smtp

Excerpts from internet.postgres: 14-Oct-94 sorry.. Praveen
Mamnani@cs.nmsu. (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
> functions (such as PQnfields(), PQgetvalue(), etc.) to get to that
> particular field (EMP.salary), for that particular employer "Bill". 

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
Mamnani@cs.nmsu. (1599) 

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

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 






 

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
