1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Rep Power

    How to get data from table and use in c++ code.


    I have a postgress table and can input to it from my code but i also want to get data out of the database to use.

    Can someone please point me in the right direction:

    My data base has 2 columns. netmask and id.

    if i request a certain id i would like returned the netmask?

    I think i use the SQL command
    PQexec("SELECT ( SELECT netmasks WHERE ID = 3) FROM netmasks;")

    But it does not return a string only a result pointer?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Rep Power
    SELECT queries always return a resultset and in your case you are selecting a record inside a record.

    I think your query should probably be:

    SELECT * FROM netmasks WHERE ID=3

    The semicolon at the end is not required and it is generally less bugsensitive if you leave it out.
    Last edited by Vinny42; November 23rd, 2013 at 09:55 AM.

IMN logo majestic logo threadwatch logo seochat tools logo