List:General Discussion« Previous MessageNext Message »
From:Rakesh Gupta Date:July 29 2005 11:23pm
Subject:Blob retrieval from database using shell
View as plain text  



Hi There,
I am trying to insert blob in table and then retrieve it from table using
Linux shell. Here is script that i used.

Load Blob into DB and Retrieve it using linux shell.
# add firmware into DB
ACTION="insert into FIRMWARE
(firmwarename, releasedate, bootcodename, usermanualname, releasenotes,
checksum, hwrevision, comments, dependencyfwid)
values (\"$FWNAME\", \"$RELDATE\", \"$BOOTNAME\", \"$MANUAL\",
LOAD_FILE(\"$FW/$1/$BRNOTES\"), \"$CHECK\", \"$HWREV\", \"$COMMENT\",
$FWDEPID);
VALUE=`echo "$ACTION" | mysql -u$APMU -p$APMPW -h$HOSTDB -D$APMDB`
if [ $? != 0 ]; then
echo $ACTION >> $LOG
echo $VALUE >> $LOG
echo [DBERR-002] >> $LOG
continue
fi

select length(firmwareimage) from FIRMWARE where firmwareid=129;


+-----------------------+
| length(firmwareimage) |
+-----------------------+
|               3763016 |
+-----------------------+

It shows the correct size of binary file

# get  blob from Database

ACTION="select firmwareimage from FIRMWARE where status !='Deleted' and
firmwareid=$1 ;"
VALUE=`echo "$ACTION" | mysql -u$APMU -p$APMPW -h$HOSTDB -D$APMDB`
if [ $? != 0 ]; then
echo $ACTION >> $LOG
echo [DBERR-001] >> $LOG
continue
fi
echo $VALUE > /tmp/tmp_129.bin

[root@apm-rg tmp]# diff ts_129.bin tmp_129.bin
Binary files ts_129.bin and tmp_129.bin differ

Retrieved binary file size increases. Does anyone know about this issue and
how to fix it.

Thread
Blob retrieval from database using shellRakesh Gupta30 Jul
  • Re: Blob retrieval from database using shellGleb Paharenko30 Jul
  • Re: Blob retrieval from database using shellEnrique Sanchez Vela31 Jul