simply google it. lot of functions available..
2009/3/31 Saju M <[email protected]>
>
>
> How can insert values from variables to Postgres database.
>
>
>
>
> #include<stdio.h>
> #include "/usr/include/libpq-fe.h"
>
> void main()
> {
>
> PGconn *conn;
> PGresult *res;
> int id;
> char name[20];
> char *qur;
>
> conn =
> PQsetdbLogin("127.0.0.1","5432",NULL,NULL,"postgres","postgres",NULL);
>
>
> if(PQstatus(conn)==CONNECTION_OK)
> {
> printf("Connection Established\n\n");
>
>
> printf("Enter the ID: \n");
> scanf("%d",&id);
> printf("Enter the NAME: \n");
> scanf("%s",&name);
> *qur="insert into table values(3,'pkv')";
> res = PQexec(conn,qur);
>
>
>
>
>
> // res = PQexec(conn,"Select * from table1");
>
> // printf("ID : %s\t",PQgetvalue(res,0,0));
> // printf("Name : %s",PQgetvalue(res,0,1));
> PQfinish(conn);
> }
> else
> {
> printf("Connection Failed\n");
> }
>
>
> }
>
>
>
> _______________________________________________
> Mailinglist mailing list
> [email protected]
> http://ilug-cochin.org/mailman/listinfo/mailinglist_ilug-cochin.org
>
>
--
Regards
Ranjith S
www.itpublic.in
Open Source Technologies
_______________________________________________
Mailinglist mailing list
[email protected]
http://ilug-cochin.org/mailman/listinfo/mailinglist_ilug-cochin.org