on 2014 Jul 24 4:32 AM
i have table with 2 column ID , Image(save file path) but i need save image as Blob in new column. i am using SQLAnywhere 12.0.1.3873
Request clarification before answering.
If the file exists on the same computer that is running the SQL Anywhere 12 engine, then see xp_read_file system procedure.
If the file exists on a different computer (say, on a client computer that is connected over the network to dbsrv12.exe running on a server computer) then see READ_CLIENT_FILE function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I understand your situation correctly, you have already a list of image file pathes in the according table but want to store the actual images there, too. So you will need to use xp_write_file() to read the file contents. (Note: That would require the database engine can access these files, i.e. they are not stored on a client computer.)
Here's a good starting point from the docs:
Insertion of documents and images
To go on further, you might use a cursor to loop over each row from the table and access the according file and insert its data via an UPDATE statement. There are also ways to do to this in one UPDATE statement, such as
UPDATE MyTable SET MyImage = xp_read_file(MyImagePath);
However, that may be a heavy burden in case you have lots of images to store, so a one-by-one approach might be easier.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i will try to use xp_read_file as "update test set blob=xp_read_file( image);"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm, then you might read that article on what SQL Anywhere can - and cannot - do to compress data:
Compressed Columns - where's the squeeze - client or server?
What kind of files are they? JPGs are already compressed so you won't be able to do much. BMPs will benefit greatly from compression, so will PNGs but to a lesser extent.
SQL Anywhere splits blob data into separate storage so it does a pretty efficient job of handling them... don't assume they will cause a performance problem, do some testing to prove it.
Are you using MobiLink synchronization? If so, there are techniques that can be used so blobs don't kill sync times.
User | Count |
---|---|
52 | |
10 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.