Yves
Yves

Reputation: 12371

libpq: get data type

I am coding a cpp project with the database "postgreSQL".

I created a table in my database its type is character varying(40).

Now I need to SELECT these data FROM the table in my cpp project. I knew that I should use the library libpq, this is the interface of "postgreSQL" for c/cpp.

I have succeeded in selecting data from the table. Now I am considering if it's possible to get the data type of this table. For example, here I want to get character varying(40).

Upvotes: 1

Views: 1480

Answers (1)

user_0
user_0

Reputation: 3363

You need to use PQftype.

As described here: http://www.idiap.ch/~formaz/doc/postgreSQL/libpq-chapter17861.htm

And just take a look here about decoding return values: http://www.postgresql.org/message-id/[email protected]

You must also use PQfsize to get field size.

Upvotes: 1

Related Questions