|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
How to insert binary data into LONG column ?
From: Claus Windeler (cw
nwt.de)
Date: Tue Jan 11 2005 - 06:14:28 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello!
I already spend several days to solve maybe a very simple problem. I just want
to insert the binary data of a file into a LONG column of my database.
I am working on Windows 2003 Server with PHP 5.0.3 and ODBC.
MaxDB version: 7.5.0.19
MaxDB Windows-ODBC driver version: 7.5.0.19
I tried the following:
$filedata = file_get_contents('test.data');
$query = 'INSERT INTO myfiles (id, filetype, filecontent, filesize) VALUES( 23,
\'test\', \''.base64_encode($filedata).'\', 299939)';
odbc_exec($connection, $query);
with the result
MySQL MaxDB][SQLOD32 DLL][MaxDB] General error;-7032 POS(1) SQL statement not
allowed for column of data type LONG
What is wrong with my SQL statement ?? Maybe the '' before and after the
filedata is not allowed, but what must I use ?? I can't find anything in the
documentation.
Later I tried the following
$stmt = odbc_prepare($connection, "INSERT INTO myfiles (id, filetype,
filecontent, filesize) VALUES( ?, ?, ?, ?)" );
$parms = array($id,$filetype,"'c:/temp/test.data'", $filesize);
$exec = odbc_execute($stmt, $parms);
This time I don't get any error messages, but only a few bytes of the file are
stored into the database ... not the complete file.
Here is the trace from the last example
INSERT INTO MYFILES (id, filetype, filecontent, filesize) VALUES( ?, ?, ?, ?)
EXECUTE: CMD :
PARSEID: INPUT : 000101B3 00004001 23000000 01000000
INPUT : 1: COLUMN1 : 2319
INPUT : 2: COLUMN2 : original
INPUT : 3: COLUMN3 : LONGVARCHAR-DESC
INPUT : 4: COLUMN4 : 12369440
LONGVAR: 3: PARAMETER :
HOSTVAR LENGTH : 131 LONGVAR LENGTH : 131
VALUE :FIRST PART : 4D4D002A00000008001100FE000400
... : 0000010000
INPUT : LONG VARCHAR FROM TO POSITION : 1 - 131
SQLERRD(INDEX_3) : 1
START : DATE : 2004-12-20 TIME : 0015:37:00
END : DATE : 2004-12-20 TIME : 0015:37:00
PUTLONG: CMD :
PARSEID: : 000101B3 00004001 23000000 01000000
LONGVAR: 3: PARAMETER :
HOSTVAR LENGTH : 0 LONGVAR LENGTH : 131
START : DATE : 2004-12-20 TIME : 0015:37:00
END : DATE : 2004-12-20 TIME : 0015:37:00
SUBTRANS END
START : DATE : 2004-12-20 TIME : 0015:37:00
END : DATE : 2004-12-20 TIME : 0015:37:00
PARSEID: DROP : 000101B3 00003D01 23000000 01000000
START : DATE : 2004-12-20 TIME : 0015:37:00
END : DATE : 2004-12-20 TIME : 0015:37:00
SQCDROPPARSID
PARSEID: : 000101B3 00003D01 23000000 01000000
PARSEID: DROP : 000101B3 00004001 23000000 01000000
START : DATE : 2004-12-20 TIME : 0015:37:00
END : DATE : 2004-12-20 TIME : 0015:37:00
SQCDROPPARSID
PARSEID: : 000101B3 00004001 23000000 01000000
It would be very nice if someone can help me to get the file into the database.
Bye
Claus Windeler
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]