How to get size of a string bind variable in OCI

From: Morten Knudsen <morten.knudsen_at_banctec.com>
Date: 16 Jul 2001 04:14:16 -0700
Message-ID: <7292353a.0107160314.4a25c796_at_posting.google.com>


How can I obtain the size/length of a bind variable in a prepared statement using OCI? I would like to know beforehand so I can allocate a buffer of the correct size. I do NOT know the size of the column at compile time. I noticed that if the column is of type CHAR, then the bind variable string has to be the same length (size) as the column and space-padded. E.g.:
"select * from employee where name=:name" If employee.name is CHAR(10) and I bind :name to 'Smith' it will not match. It has to be bound to 'Smith ' (space padded to 10 chars).

I have tried to do
OCIGetAttr(bind_h, OCI_HTYPE_BIND, &colsize, 0, OCI_ATTR_MAXDATA_SIZE¤, err_h) which seems like the right thing to do, but it always returns 0. This is of course after running OCIBindByName()

Any help is appreciated.

Morten Received on Mon Jul 16 2001 - 13:14:16 CEST

Original text of this message