Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into DB2 VarChar Field

Status
Not open for further replies.

jtrapat1

Programmer
Jan 14, 2001
137
0
0
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top