|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
casting to longthose files and loads them into a SQL-Serverd atabase table. One of the fields in my table is a 600 byte binary field. The field stores a 600 byte data structure in my C++ program,' A'. The C++ structure is comprised of char arrays, long, double, float, etc... no pointers, just a block of memory. I populate the binary field using a CRecordset and CByteArray. RFX_Binary does the work. Pretty standard stuff. I do an AddNew(), assign the key fields, put the structure in the CByteArray and call Update(). All that seems fine. Here's why i'm doing it this way. We frequenty use "reserved" space in the 600 byte C++ structure when we need to add something. My idea is to create a view that converts substrings of the binary structure to the appropriate type. That way, we don't have toc hange program 'B' I described above everytime we change the structure in' A'. I would simply modify the view and add a cast() where the previously unused space was. 'B' wouldn't care what's in it, it would just put it in the database. Here's my problem. cast(substring(mybinaryblob, 253, 4) as int) as count, doesn't work. N either does cast(substring(mybinaryblob, 124, 4) as money) as Price. All the other fields seem to work. The Count in the C++ struct is a long and Price is a float. They're just not casting right. Initially I tried to convert count to a float but that's not allowed. I'd prefer to not make all my longs and floats actual fields in the table, I'd rather cast() or convert() them in the view. Any help would be greatly appreciated. -TIA The sturct is basically this. struct { long Count; float Price; many more members here. char reserved[123]; } Hi
It would be useful if you posted DDL and example data with the values you expect! http://www.aspfaq.com/etiquettÂe.asp?id=5006. John Show quote "Nobody" wrote: > I have two programs, A & B. 'A' creates large data files and 'B' takes > those files and loads them into a SQL-Serverd atabase table. One of the > fields in my table is a 600 byte binary field. The field stores a 600 byte > data structure in my C++ program,' A'. The C++ structure is comprised of > char arrays, long, double, float, etc... no pointers, just a block of > memory. I populate the binary field using a CRecordset and CByteArray. > RFX_Binary does the work. Pretty standard stuff. I do an AddNew(), assign > the key fields, put the structure in the CByteArray and call Update(). All > that seems fine. > > Here's why i'm doing it this way. We frequenty use "reserved" space in the > 600 byte C++ structure when we need to add something. My idea is to create > a view that converts substrings of the binary structure to the appropriate > type. That way, we don't have toc hange program 'B' I described above > everytime we change the structure in' A'. I would simply modify the view > and add a cast() where the previously unused space was. 'B' wouldn't care > what's in it, it would just put it in the database. > > Here's my problem. cast(substring(mybinaryblob, 253, 4) as int) as count, > doesn't work. N either does cast(substring(mybinaryblob, 124, 4) as money) > as Price. All the other fields seem to work. The Count in the C++ struct > is a long and Price is a float. They're just not casting right. Initially > I tried to convert count to a float but that's not allowed. > > I'd prefer to not make all my longs and floats actual fields in the table, > I'd rather cast() or convert() them in the view. > > Any help would be greatly appreciated. > > > -TIA > > > The sturct is basically this. > > struct > { > long Count; > float Price; > many more members here. > char reserved[123]; > } > > > |
|||||||||||||||||||||||