Thread: want basic help with C
hi, i went thru the docs on programming interface of postgresql with c. But am unable to understnad to use the interface to query a select statement. the database is--->masterdb & in it there is a table -->colleges with a few columns & a few records for testing.. now i want to use a general select statement--> select * from colleges, but going thru the docs again & again from different sites am unable to undestand how to use it. can u gove me a basics to use the funstion to use the same & print the rows in the tables thanking in advance A.H
Arindam Haldar wrote: hi, i went thru the docs on programming interface of postgresql with c. But am unable to understnad to use the interface to query a select statement. the database is--->masterdb & in it there is a table -->colleges with a few columns & a few records for testing.. now i want to use a general select statement--> select * from colleges, but going thru the docs again & again from different sites am unable to undestand how to use it. can u gove me a basics to use the funstion to use the same & print the rows in the tables thanking in advance A.H pls--> i wanted to ask this 2nd Question-->is it necessary to start postgreswith option -i too to accept connection from localhost(C programme). command line works fine without the said option but unless i use -i , i cannot connect to postgres.
thanx so much buddy ... it worked ! :) Shawn Stephens - Q Data KZN wrote: > I don't know if this will help. You just need to substitute your database > name, table name and field names. > > > > Kind Regards > > Shawn Stephens > Oracle Database Administrator > > For: Comparex Africa (Pty) Ltd > Company Registration Number: 1993/003683/07 > > Tel : + 27 (0) 31 560 6309 > Fax : + 27 (0) 31 560 6399 > <mailto:shawns@ComparexAfrica.co.za> > > NOTICE: This message and any attachments are confidential and intended > solely for the addressee. If you have received this message in error, please > notify Shawn Stephens at Comparex Africa (Pty) Ltd immediately, telephone > number +27 (0) 31 560 6309. Any unauthorised use, alteration or > dissemination is prohibited. Comparex Africa (Pty) Ltd accepts no liability > whatsoever for any loss whether it be direct, indirect or consequential, > arising from information made available and actions resulting there from. > > > -----Original Message----- > From: Arindam Haldar [mailto:arindamhaldar@hotpop.com] > Sent: 21 May 2002 02:17 > To: pgsql-interfaces@postgresql.org; pgsql-general@postgresql.org > Subject: [INTERFACES] want basic help with C > > > hi, > i went thru the docs on programming interface of postgresql with c. But > am unable to understnad to use the interface to query a select > statement. the database is--->masterdb & in it there is a table > -->colleges with a few columns & a few records for testing.. > now i want to use a general select statement--> select * from colleges, > but going thru the docs again & again from different sites am unable to > undestand how to use it. > can u gove me a basics to use the funstion to use the same & print the > rows in the tables > > thanking in advance > A.H > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org >
On Tue, 2002-05-21 at 13:34, Arindam Haldar wrote: > Arindam Haldar wrote: > hi, > i went thru the docs on programming interface of postgresql with c. But This is the libpq interface, yes? You need to read the libpq reference: chapter 1 of the Programmer's Guide. > am unable to understnad to use the interface to query a select > statement. the database is--->masterdb & in it there is a table > -->colleges with a few columns & a few records for testing.. > now i want to use a general select statement--> select * from colleges, > but going thru the docs again & again from different sites am unable to > undestand how to use it. > can u gove me a basics to use the funstion to use the same & print the > rows in the tables First you have to connect to the database, using PQconnectdb() or a related function. This returns a handle which you have to use in all other API calls for this connection. Send your command or query to the backend with PQExec() This returns a query handle which you can use to get the results with the various calls listed in section 1.3.4 of the Programmer's Guide. Close the connection with PQfinish() > pls--> i wanted to ask this 2nd Question-->is it necessary to start > postgreswith option -i too to accept connection from localhost(C > programme). command line works fine without the said option but unless i > use -i , i cannot connect to postgres. If you connect through TCP/IP you always need the -i option on the postmaster. Connecting with host set to localhost is a TCP/IP connection. Connecting with host set to nothing connects through a Unix socket on the local machine; this does not need the -i option. -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C "O come, let us worship and bow down; let us kneel before the LORD our maker." Psalms 95:6