Thread: ...
Hello, I have a new linux system running RedHat 7.2. The Postgreqsl installation I have is the one that came with RH. I downloadedall the pdfs for Administration, Programmer, Tutorial, etc. I am trying to write a simple C program to use thedatabase I just created. My command line looks like this: gcc -Wall -o test1 test1.c From this, I get a long list of 'Undefined Reference' errors for any function that starts with 'PQ'. I assume I am missing a library or something. I am new to Linux programming (although I am an experienced C/C++ programmerunder windows). What am I missing? Thanks in advance. Andrew Pierce
Looks like you're missing the "-lpq" linker reference. Also, don't forget to include the "/usr/include/pgsql/libpq-fe.h" file in your source. (You know the drill ... #include <pgsql/libpq-fe.h> ) Check out the Programmer docs closely, they helped me a lot. Best regards, amp wrote: > Hello, > > I have a new linux system running RedHat 7.2. The Postgreqsl installation I have is the one that came with RH. I downloadedall the pdfs for Administration, Programmer, Tutorial, etc. I am trying to write a simple C program to use thedatabase I just created. My command line looks like this: > > gcc -Wall -o test1 test1.c > > >From this, I get a long list of 'Undefined Reference' errors for any function that starts with 'PQ'. > > I assume I am missing a library or something. I am new to Linux programming (although I am an experienced C/C++ programmerunder windows). > > What am I missing? Thanks in advance. > > Andrew Pierce > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > > -- John Burski I.T. Manager and Systems Administration 911 Emergency Products, Inc. 25 Sixth Avenue North Saint Cloud, MN 56303 John.Burski@911ep.com 800-863-6911, extension 221 FAX: 800-863-2991 www.911ep.com
This was correctly answered on another list by Steve Miskovitz. I am posting it here for those of you who have been working this. There is more in depth info about the sql technique heuses in his solution at the SQL Tutor: http://w3.one.net/~jhoffman/sqltut.htm#More_Subqueries It is essentially a NOT EXISTS in a (subquery) Here is the answer which I copied and pasted making the appropriate table name and field changes into my real world application,(though magic could be cool.) --------------------------- from: Steve Miskovitz <steve@collegepublisher.com> --------------------------- Subject: RE: SQL Question here is a straight forward way : SELECT TR.1_id FROM Trick TR WHERE NOT EXISTS ( SELECT * FROM Trick-Magician-Knows TMK WHERE TMK.1_id = TR.1_id AND TMK.2_id = ?) So it selects all tricks that DO NOT have a corresponding entry in the Trick-Magician-Knows table for a given magician. Switch the ? with 2_id of the magician.