on 2023 Jan 24 9:19 AM
Grüße Euch, wie schreibt an SQL z.B. eine .JPG Imagedatei in ein IMAGE Feld?
VG Franz
Request clarification before answering.
You can use xp_read_file() to load the file's contents, and then just use the return value as value within an INSERT and/or UPDATE statement, such as
UPDATE MyTable SET MyImage = xp_read_file('c:\\\\Gallery\\\\MyTest.jpg') WHERE ID = 1;
Column MyTable should be of LONG BINARY (or IMAGE) data type. This should work for any kind of BLOBs (binary large objects).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Similarly you can use xp_write_file() to store a BLOB's contents in a OS file, such as
SELECT xp_write_file('c:\\\\Gallery\\\\MyTestKopie.jpg', MyImage) FROM MyTable WHERE ID = 1;
Of course, you can also use local variables within SQL to handle BLOBs, such as
begin declare myVar long binary; set myVar = xp_read_file('c:\\\\Gallery\\\\MyTest.jpg'); xp_write_file(myBlob, ('c:\\\\Gallery\\\\MyTestKopie.jpg', myVar); end;
Both file functions are server-based and use path specifications that must be accessible for the database engine. For client-side access, you can use READ_CLIENT_FILE() resp. WRITE_CLIENT_FILE().
The type of file stored in a BLOB has nothing to do with SQL Anywhere...
AFAIK, most picture formats will have identifying values in the first bytes of the contents - but it sure would be waaayyyy easier to store the file name and/or MIME type when storing the file contents, so it is already available when you want to export the file. 🙂
User | Count |
---|---|
75 | |
30 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.