agora inbox for pgsql-interfaces@postgresql.org  
help / color / mirror / Atom feed
C where are oids defined?
3+ messages / 2 participants
[nested] [flat]

* C where are oids defined?
@ 2014-07-15 15:36  frank ernest <doark@mail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: frank ernest @ 2014-07-15 15:36 UTC (permalink / raw)
  To: pgsql-interfaces

Hi, I'm new and I can't seem to figure out what values are permitted for OID
PQexecPrepared(parrentcon, insertstmt, 2, argz_str, //fixme);
I've looked in the docs but it's simply evading me. In C the values are of type char * and in the database they are of type varchar(255).

Thanks


-- 
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: C where are oids defined?
@ 2014-07-15 16:09  Jeff Davis <pgsql@j-davis.com>
  parent: frank ernest <doark@mail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Jeff Davis @ 2014-07-15 16:09 UTC (permalink / raw)
  To: frank ernest <doark@mail.com>; +Cc: pgsql-interfaces

On Tue, 2014-07-15 at 17:36 +0200, frank ernest wrote:
> Hi, I'm new and I can't seem to figure out what values are permitted for OID
> PQexecPrepared(parrentcon, insertstmt, 2, argz_str, //fixme);
> I've looked in the docs but it's simply evading me. In C the values are of type char * and in the database they are of type varchar(255).

It looks like you're talking about PQprepare(), not PQexecPrepared().

You can just use NULL for the paramTypes argument, and normally postgres
will figure out the type and everything will be fine. Specifying the
types might catch certain kinds of mistakes and might save postgres a
small amount of work.

To specify the types, the OID is the internal ID of the postgres type.
For built-in types, this is constant, and most people #include
"catalog/pg_type.h". That allows you to use a name, like VARCHAROID,
INT4OID, etc.

For user-defined types, the OID might be different on different servers,
so it's quite awkward to specify the OID for a user-defined type.

Regards,
	Jeff Davis




-- 
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: C where are oids defined?
@ 2014-07-15 16:19  frank ernest <doark@mail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: frank ernest @ 2014-07-15 16:19 UTC (permalink / raw)
  To: pgsql-interfaces

> You can just use NULL for the paramTypes argument, and normally postgres
> will figure out the type and everything will be fine. Specifying the
> types might catch certain kinds of mistakes and might save postgres a
> small amount of work.

I like being type safe whenever possible, it's the first thing you [should] learn in C and one less variable when debugging.

> For user-defined types, the OID might be different on different servers,
> so it's quite awkward to specify the OID for a user-defined type.

The server is going to be run locally so that's not a problem.

Thanks


-- 
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2014-07-15 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15 15:36 C where are oids defined? frank ernest <doark@mail.com>
2014-07-15 16:09 ` Jeff Davis <pgsql@j-davis.com>
2014-07-15 16:19 Re: C where are oids defined? frank ernest <doark@mail.com>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox