I need to know the best way to insert data into a varchar field in a db2 table to optimize space and performance.
Here's how the db2 field is defined:
--------------------------------
struct
{
varchar purpose_desc[400];
varchar length;
}purpose[400+1];
---------------------------------
Now, I'm trying to insert from a C Program and the dba tells me that there is a lot of wasted space when I do my insert.
Here's my C code:
I'm reading from a struct and copying to a host variable.
------------------------------------------
strcpy(bp12.purpose,adds.purpose);
------------------------------
My adds.purpose field is defined as
char purpose[240]
so you can see that there is a lot of space empty after the insert.
------------------------------
Sometimes the value inserted is blank or spaces and it still fills up the entire varchar field.
What is the best way to do this insert from C?
Or, are there some string functions I could use to strip away the trailing spaces before inserting the value?
Thanks in Advance
John
Here's how the db2 field is defined:
--------------------------------
struct
{
varchar purpose_desc[400];
varchar length;
}purpose[400+1];
---------------------------------
Now, I'm trying to insert from a C Program and the dba tells me that there is a lot of wasted space when I do my insert.
Here's my C code:
I'm reading from a struct and copying to a host variable.
------------------------------------------
strcpy(bp12.purpose,adds.purpose);
------------------------------
My adds.purpose field is defined as
char purpose[240]
so you can see that there is a lot of space empty after the insert.
------------------------------
Sometimes the value inserted is blank or spaces and it still fills up the entire varchar field.
What is the best way to do this insert from C?
Or, are there some string functions I could use to strip away the trailing spaces before inserting the value?
Thanks in Advance
John