Copystream on BLOB fields

haksve
Member Posts: 17
I Try to add all the blobreferences in Table "Objects" into a file. However the Copystream command causes MBS NAV (5.1) to crash. any ideas?
FilePath := 'C:\QQQ\CCChecksum.BIN';
DestinationFile.WRITEMODE(TRUE);
DestinationFile.TEXTMODE(FALSE);
DestinationFile.CREATE(FilePath);
DestinationFile.CREATEOUTSTREAM(Outstr);
ObjectTable."BLOB Reference".CREATEINSTREAM(Instr);
ObjectTable.RESET;
ObjectTable.SETFILTER(Type,
'%1|%2|%3|%4|%5|%6|%7',
ObjectTable.Type::Table,
ObjectTable.Type::Form,
ObjectTable.Type::Report,
ObjectTable.Type::Dataport,
ObjectTable.Type::Codeunit,
ObjectTable.Type::XMLport,
ObjectTable.Type::MenuSuite
);
ObjectTable.FINDSET;
REPEAT
ObjectTable.CALCFIELDS(ObjectTable."BLOB Reference");
IF ObjectTable."BLOB Reference".HASVALUE THEN BEGIN
IF NOT COPYSTREAM(Outstr,Instr) THEN
ERROR('COPYSTREAM failed');
END;
UNTIL ObjectTable.NEXT = 0;
FilePath := 'C:\QQQ\CCChecksum.BIN';
DestinationFile.WRITEMODE(TRUE);
DestinationFile.TEXTMODE(FALSE);
DestinationFile.CREATE(FilePath);
DestinationFile.CREATEOUTSTREAM(Outstr);
ObjectTable."BLOB Reference".CREATEINSTREAM(Instr);
ObjectTable.RESET;
ObjectTable.SETFILTER(Type,
'%1|%2|%3|%4|%5|%6|%7',
ObjectTable.Type::Table,
ObjectTable.Type::Form,
ObjectTable.Type::Report,
ObjectTable.Type::Dataport,
ObjectTable.Type::Codeunit,
ObjectTable.Type::XMLport,
ObjectTable.Type::MenuSuite
);
ObjectTable.FINDSET;
REPEAT
ObjectTable.CALCFIELDS(ObjectTable."BLOB Reference");
IF ObjectTable."BLOB Reference".HASVALUE THEN BEGIN
IF NOT COPYSTREAM(Outstr,Instr) THEN
ERROR('COPYSTREAM failed');
END;
UNTIL ObjectTable.NEXT = 0;
0
Comments
-
why not do the following
if object.findset then repeat
object.calcfields(Blob reference");
object.export('c:\object.file',false);
until object.next = 0;0 -
What's the reason, that you need this?
Are there in the file only the BLOB reference or some more?
If the BLOB Ref. is only in the file use ara3n's solution.
If you want to stream more in the file, try this:RecObject.GET(5,'',1); RecObject.CALCFIELDS(RecObject."BLOB Reference"); if RecObject."BLOB Reference".HASVALUE then begin Myfile.CREATE('C:\Downloads\zzzz.txt'); //Myfile.SEEK(TheNeededPosition); RecObject."BLOB Reference".CREATEInSTREAM(IStream); Myfile.CREATEOutSTREAM(OStream); COPYSTREAM(OStream,IStream); Myfile.CLOSE; end;
RegardsDo you make it right, it works too!0 -
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Answer to Garak:
The reason is that I will use the file to calculate a checksum for the total of all objects.
As far as I can see Your suggestion is doing the same thing as my code, execept that my code loops and concatenates all the blob references
Best Regards0 -
Answer to ara3n:
The export function will overwrite the file instead of adding to it.
Best Regards0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions