vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Version: Sybase 12.5.1 I have a table with a varbinary(255) field. When i try to insert this varbinary "0x0400010000" in my table, i can see thet last two bytes are inesistent. select my_field from my tables go I have this output: 0x040001 Why???How can i solve this problem??? Thanks in Advance. |
| |||
| select bintostr (my_field) from ... may solve your problem. I'm not sure as to when this function became available. "FCA" <marakaimbo@libero.it> wrote in message news:c4u5jc$2l1cr2$1@ID-110320.news.uni-berlin.de... > Version: Sybase 12.5.1 > I have a table with a varbinary(255) field. > > When i try to insert this varbinary "0x0400010000" in my table, i can see > thet last two bytes are inesistent. > > select my_field from my tables > go > > > I have this output: > 0x040001 > > Why???How can i solve this problem??? > Thanks in Advance. > > > > > > > |
| |||
| Tahnk yuo "Carl Kayser" But this is not my problem. My problem is that, when I try to insert a virbinary that have last byte to 00 i have this situation: insert into my_table select 0x0400010000 go select * from my_table go my_field --------- 0x040001 where is 0000? "Carl Kayser" <kayser_c@bls.gov> wrote in message news:c4uajp$ats$1@blsnews.bls.gov... > > select bintostr (my_field) from ... may solve your problem. I'm not sure > as to when this function became available. > > > "FCA" <marakaimbo@libero.it> wrote in message > news:c4u5jc$2l1cr2$1@ID-110320.news.uni-berlin.de... > > Version: Sybase 12.5.1 > > I have a table with a varbinary(255) field. > > > > When i try to insert this varbinary "0x0400010000" in my table, i can see > > thet last two bytes are inesistent. > > > > select my_field from my tables > > go > > > > > > I have this output: > > 0x040001 > > > > Why???How can i solve this problem??? > > Thanks in Advance. > > > > > > > > > > > > > > > > |
| |||
| On Tue, 06 Apr 2004 16:53:30 +0200, FCA wrote: > Tahnk yuo "Carl Kayser" > > But this is not my problem. > My problem is that, when I try to insert a virbinary that have last byte > to 00 i have this situation: > > insert into my_table select 0x0400010000 go > > select * from my_table > go > > my_field > --------- > 0x040001 > > where is 0000? It got truncated. That "bug" has been around in Sybase since 4.0 - I remember hitting it when storing a string of bytes as a varbinary and losing any trailing NULL bytes. I worked around it by putting an end marker (I think I used 0x7f) as the last byte of the string, and have my front end clean it up as needed. Personally I think this is a bug - a varbinary should store what you give it, trailing null bytes included. You may want to open a case with Sybase Tech Support. Michael -- Michael Peppler Data Migrations, Inc. mpeppler@peppler.org http://www.peppler.org/ Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or long term contract positions - http://www.peppler.org/resume.html |
| |||
| Since this is varbinary, the trailing eroes are suppressed by default -- they haven't not disappeared but they're just not displayed. In other words, it's a formatting issue. Try doing a convert to binary(255) and you'll see what I mean... HTH, Rob ------------------------------------------------------------- Rob Verschoor Certified Sybase Professional DBA for ASE 12.5/12.0/11.5/11.0 and Replication Server 12.5 Author of "Tips, Tricks & Recipes for Sybase ASE" and "The Complete Sybase ASE Quick Reference Guide" Online orders accepted at http://www.sypron.nl/shop mailto:rob@YOUR.SPAM.sypron.nl.NOT.FOR.ME http://www.sypron.nl Sypron B.V., P.O.Box 10695, 2501HR Den Haag, The Netherlands ------------------------------------------------------------- "FCA" <marakaimbo@libero.it> wrote in message news:c4ug4u$2nanlk$1@ID-110320.news.uni-berlin.de... > Tahnk yuo "Carl Kayser" > > But this is not my problem. > My problem is that, when I try to insert a virbinary that have last byte to > 00 i have this situation: > > insert into my_table select 0x0400010000 > go > > select * from my_table > go > > my_field > --------- > 0x040001 > > where is 0000? > > > > "Carl Kayser" <kayser_c@bls.gov> wrote in message > news:c4uajp$ats$1@blsnews.bls.gov... > > > > select bintostr (my_field) from ... may solve your problem. I'm not sure > > as to when this function became available. > > > > > > "FCA" <marakaimbo@libero.it> wrote in message > > news:c4u5jc$2l1cr2$1@ID-110320.news.uni-berlin.de... > > > Version: Sybase 12.5.1 > > > I have a table with a varbinary(255) field. > > > > > > When i try to insert this varbinary "0x0400010000" in my table, i can > see > > > thet last two bytes are inesistent. > > > > > > select my_field from my tables > > > go > > > > > > > > > I have this output: > > > 0x040001 > > > > > > Why???How can i solve this problem??? > > > Thanks in Advance. > > > > > > > > > > > > > > > > > > > > > > > > > > > |
| |||
| "FCA" <marakaimbo@libero.it> wrote in message news:<c4u5jc$2l1cr2$1@ID-110320.news.uni-berlin.de>... > Version: Sybase 12.5.1 > I have a table with a varbinary(255) field. > > When i try to insert this varbinary "0x0400010000" in my table, i can see > thet last two bytes are inesistent. > > select my_field from my tables > go > > > I have this output: > 0x040001 > > Why???How can i solve this problem??? > Thanks in Advance. Why? Because that is the documented behavior. Please read the ASE Reference Manual, Vol 1 on "Binary" datatypes. "Treatment of trailing zeroes All binary not null columns are padded with zeros to the full width of the column. Trailing zeros are truncated in all varbinary data and in binary null columns, since columns that accept null values must be treated as variable-length columns." You can either assume that a bytes following this value are 0x00 or, if the exact number of 0x00 bytes is important to you, append some non-zero byte to the end of every binary value you store, i.e. instead of storing "0x0400010000", store "0x0400010000ff" and have your application always strip off the last byte. -bret |
| ||||
| Michael Peppler <mpeppler@peppler.org> wrote in message news:<pan.2004.04.06.15.06.07.479622@peppler.org>. .. > On Tue, 06 Apr 2004 16:53:30 +0200, FCA wrote: > > > Tahnk yuo "Carl Kayser" > > > > But this is not my problem. > > My problem is that, when I try to insert a virbinary that have last byte > > to 00 i have this situation: > > > > insert into my_table select 0x0400010000 go > > > > select * from my_table > > go > > > > my_field > > --------- > > 0x040001 > > > > where is 0000? > > It got truncated. > > That "bug" has been around in Sybase since 4.0 - I remember hitting it > when storing a string of bytes as a varbinary and losing any trailing NULL > bytes. I worked around it by putting an end marker (I think I used 0x7f) > as the last byte of the string, and have my front end clean it up as > needed. > > Personally I think this is a bug - a varbinary should store what you give > it, trailing null bytes included. You may want to open a case with Sybase > Tech Support. > > Michael If you do, indicate that you are expressing an interest in seeing feature request CR 290256 implemented. This request is for char and binary datatypes that neither strip trailing spaces and nulls nor pad the value with spaces and nulls. -bret |