X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C57A7D1B379 for ; Wed, 30 Jun 2004 10:26:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60245-05 for ; Wed, 30 Jun 2004 13:26:54 +0000 (GMT) Received: from ns.mactan.ph (unknown [203.177.22.151]) by svr1.postgresql.org (Postfix) with ESMTP id B69A6D1B352 for ; Wed, 30 Jun 2004 10:26:44 -0300 (ADT) Received: from cache ([203.177.22.134]) by ns.mactan.ph (8.9.3/8.9.3) with SMTP id WAA08987 for ; Wed, 30 Jun 2004 22:05:15 +0800 Message-ID: <000b01c45ea5$def68850$8616b1cb@cache> Reply-To: "apellido jr., wilfredo p." From: "apellido jr., wilfredo p." To: Subject: help !!! Date: Wed, 30 Jun 2004 21:26:06 +0800 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.3 tagged_above=0.0 required=5.0 tests=PLING_PLING X-Spam-Level: * X-Archive-Number: 200406/75 X-Sequence-Number: 5003 Hello! im a newbie in C programing as well as Postgresql. The above example is workin but im having difficulty regarding assigning the result of Query Select. here's the program int main() { char UserName[50]; /* holds user state code */ char query_string[256]; /* holds constructed SQL query */ PGconn *conn; /* holds database connection */ PGresult *res; /* holds query result */ conn = PQconnectdb("dbname=grade"); /* connect to the database */ if (PQstatus(conn) == CONNECTION_BAD) /* did the connection fail? */ { fprintf(stderr, "Connection to database failed.\n"); fprintf(stderr, "%s", PQerrorMessage(conn)); exit(1); } printf("Enter Username: "); /* prompt user for a state code */ scanf("%s", UserName); sprintf(query_string, /* create an SQL query string */ "SELECT username, value FROM table1 where test = 'grade' and username = '%s'", UserName); res = PQexec(conn, query_string); /* send the query */ if (PQresultStatus(res) != PGRES_TUPLES_OK) /* did the query fail? */ { fprintf(stderr, "SELECT query failed.\n"); PQclear(res); PQfinish(conn); exit(1); } printf("\n\n\n"); printf("Username : %s\n\n\n", PQgetvalue(res, 0, 0)); printf("Grade : %s \n\n\n", PQgetvalue(res, 0, 1)); PQclear(res); /* free result */ PQfinish(conn); /* disconnect from the database */ return 0; } ############################################################################ ######## hello how can i assign to certain variable the output of PQgetvalue(res, 0, 1)? example i want to do like this ... a = PQgetvalue(res, 0, 1) printf("Grade : %s \n\n\n", a ); and then after assigning the value of PQgetvalue(res, 0, 1) to a then ... b = a \ 2; but it is possible to divide the output of "a" where it is a var and "b" is integer?