Harsh,
Are you talking about a 'host variable'? In that case look at the declared
size of the field as in:
NBRAHMS:8.04:GOULET> desc module_master
Name Null? Type
---------------------------------------- -------- --------------
MODULE_ID NOT NULL VARCHAR2(13)
MODEL_NUMBER NOT NULL VARCHAR2(20)
SERIAL_NUMBER VARCHAR2(15)
LAST_TEST_DATE DATE
ARCH_TAPE_ID NUMBER
Now to declare a host variable for this tables stuff I'd use:
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR module_id[14];
VARCHAR model_number[21];
VARCHAR serial_number[16];
VARCHAR last_test_date[12];
int arch_tape_id;
EXEC SQL END DECLARE SECTION;
The point is that for each character data type you need to allow for a full
variable + one for the null terminator. This is because Oracle does not null
terminate the data when it hands it back so since a VARCHAR data type is a
structure you have both the character data & the length as in:
/*VARCHAR model_number[21] */
struct
{ arr[21];
len;
}model_number;
So after retrieving a data point you need to:
model_number.arr[model_number.len] = '\0';
Dick Goulet
____________________Reply Separator____________________
Author: Harsh Agrawal <[EMAIL PROTECTED]>
Date: 3/12/2001 5:30 AM
Hi,
I have a table containing CHAR, VARCHAR2, NUMBER and DATE fields.
Is there any way or command to find out the record length in bytes.
This can be useful while defining a Buffer in Pro*C to handle a record.
Thanks in Advance.
= Harsh
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Harsh Agrawal
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author:
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).