![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want to store files in a database, I have absolute no clue how I do this. I have a structure like this: typedef struct DB_DOCUMENTBASE { DWORD NDX; char HEADING[100+1]; DWORD DATALEN; char *DATA; // Actual file } DOCUMENTBASE; DOCUMENTBASE db; I create the file with: FileBuf.RecLen = 255; FileBuf.PageSize = 1024; FileBuf.FILEFLAGS = VAR_RECS; ....... So when I want to insert a new record I alloc memory (calloc) db.DATALEN = filelength; db.DATA = calloc(db.DATALEN,sizeof(char)); copy the file into the db.DATA But then I have no clue how I insert the data into btrieve. How do I tell the length of the data to btrieve? And how do I receive the data again. Can I use G_GET_EQUAL, B_GET_FIRST as usual And if the buffer is to low I receive status 22. But is the data copied into my buffer? Example: I want to step thru the hole database without receiving the file. Can I allocate a buffer large enough to hold the first part and handle status 22 like status 0? Regards, GTi |
#3
| |||
| |||
|
|
You must use the Get Direct / Get Chunk operation, each time the portion is greater than 64k you will receive stat 22, which is not a failure. Once you reach the end of the record, you will get a stat 0. Your app must keep track of the offset and length of each 'chunk' of data. In answer to your last question, status 22 is not a failure, it just means that the entire record could not fit in your buffer, so yes - treat it as a stat 0. Best Regards, Michael Hovis Pervasive Software "GTi" <nospam (AT) online (DOT) com> wrote in message news:RtJYa.21753$KF1.309204 (AT) amstwist00 (DOT) .. I want to store files in a database, I have absolute no clue how I do this. I have a structure like this: typedef struct DB_DOCUMENTBASE { DWORD NDX; char HEADING[100+1]; DWORD DATALEN; char *DATA; // Actual file } DOCUMENTBASE; DOCUMENTBASE db; I create the file with: FileBuf.RecLen = 255; FileBuf.PageSize = 1024; FileBuf.FILEFLAGS = VAR_RECS; ....... So when I want to insert a new record I alloc memory (calloc) db.DATALEN = filelength; db.DATA = calloc(db.DATALEN,sizeof(char)); copy the file into the db.DATA But then I have no clue how I insert the data into btrieve. How do I tell the length of the data to btrieve? And how do I receive the data again. Can I use G_GET_EQUAL, B_GET_FIRST as usual And if the buffer is to low I receive status 22. But is the data copied into my buffer? Example: I want to step thru the hole database without receiving the file. Can I allocate a buffer large enough to hold the first part and handle status 22 like status 0? Regards, GTi |
#4
| |||
| |||
|
|
Mike, Thank you for the answer, but I still don't get it. Is there any c/c++ example available? Now I'm really confused. Must I read the database just like a ordinary file. Always remember the offset byte for byte from the beginning of the file. Is searching based on a KEY not possible? Must I read the database from the beginning and read through all records (with "files") until I reach the key? I must be misapprehension you answer. Please explain me how this is done. In my example: NDX and HEADING is a key: GTi "Mike Hovis" <mhovisNOSPAM (AT) pervasive (DOT) com> wrote in message news:HUPYa.935$4B7.661 (AT) newssvr23 (DOT) news.prodigy.com... You must use the Get Direct / Get Chunk operation, each time the portion is greater than 64k you will receive stat 22, which is not a failure. Once you reach the end of the record, you will get a stat 0. Your app must keep track of the offset and length of each 'chunk' of data. In answer to your last question, status 22 is not a failure, it just means that the entire record could not fit in your buffer, so yes - treat it as a stat 0. Best Regards, Michael Hovis Pervasive Software "GTi" <nospam (AT) online (DOT) com> wrote in message news:RtJYa.21753$KF1.309204 (AT) amstwist00 (DOT) .. I want to store files in a database, I have absolute no clue how I do this. I have a structure like this: typedef struct DB_DOCUMENTBASE { DWORD NDX; char HEADING[100+1]; DWORD DATALEN; char *DATA; // Actual file } DOCUMENTBASE; DOCUMENTBASE db; I create the file with: FileBuf.RecLen = 255; FileBuf.PageSize = 1024; FileBuf.FILEFLAGS = VAR_RECS; ....... So when I want to insert a new record I alloc memory (calloc) db.DATALEN = filelength; db.DATA = calloc(db.DATALEN,sizeof(char)); copy the file into the db.DATA But then I have no clue how I insert the data into btrieve. How do I tell the length of the data to btrieve? And how do I receive the data again. Can I use G_GET_EQUAL, B_GET_FIRST as usual And if the buffer is to low I receive status 22. But is the data copied into my buffer? Example: I want to step thru the hole database without receiving the file. Can I allocate a buffer large enough to hold the first part and handle status 22 like status 0? Regards, GTi |
![]() |
| Thread Tools | |
| Display Modes | |
| |