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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to length of varchar ?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a field of varchar in a table. I have defined it as follows along with other fields
xyz varchar(10).
I have inserted one row with 5 chars for this field so this field will occupy only 5 bytes or characters and I have inserted another record with 10 chars for this field so this field for this record will occupy only 10 bytes or characters
Now i give a select on this table for all rows i.e. select * from abc.
In spufi it will show 2 records with the first record showing 5 chars and 5 spaces for this field and for second record it will show the 10 characters. What I wanted to know is that how do I know a that how many fields is a varchar field occupying for each record.

I heard that DB2 stores 2 bytes for each record's varchar's field. So that 2 bytes contains information about the length of the bytes occupied by the varchar variable. So if this is correct how can we see that 2 bytes of information.




 
Suggest you repost this one in the DB2 forum of this website.
 
Hi Cidc,

As I recall (I don't have a manual handy) you have to define the field as:
05 var-fld.
49 vf-len pic s9(004).
49 vf-data pic x(010).

It's the pgmr's(you) responsiblity to calc the real len of the variable and move the len to vf-len and the data to vf-data.

As I said, no manual; check it for accuracy.

Regards, Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top