如何insert 入blob字段
1个回答
展开全部
您好,我在别的论坛也看到您的问蠢薯山题,很高兴为您解手胡答:
EXEC SQL BEGIN DECLARE SECTION;
......
sqlint32 ImgID;
SQL TYPE IS BLOB(1 M) _11Images;
EXEC SQL END DECLARE SECTION;
typedef struct ImgInfo
{
int ImageNo;
char * ImgData;
}T_ImgInfo;
int Insert_ImageResult(T_ImgInfo * Rec, int nRow)
{
int iRes = 0;
for(int i = 0; i <带中 nRow; i++)
{
_11Images.length = DecodeBase64(Rec.ImgData, _11Images.data, strlen(Rec.ImgData)); //Rec.ImgData为图象数据的base64编码,此处DecodeBase64将Rec.ImgData解码并将结果存_11Images.data。
printf("_11Images.data = %s. _11Images.length = %d. \n", _11Images.data, _11Images.length);
ImgID = Rec.ImageNo;
EXEC SQL INSERT INTO IMAGERESULT VALUES(:ImgID,
printf("EXEC SQL INSERT INTO IMAGERESULT";
if (SQLCODE!=0) { iRes = SQLCODE; break}
}
if (iRes != 0) EXEC SQL ROLLBACK;
else EXEC SQL COMMIT;
return iRes;
}
EXEC SQL BEGIN DECLARE SECTION;
......
sqlint32 ImgID;
SQL TYPE IS BLOB(1 M) _11Images;
EXEC SQL END DECLARE SECTION;
typedef struct ImgInfo
{
int ImageNo;
char * ImgData;
}T_ImgInfo;
int Insert_ImageResult(T_ImgInfo * Rec, int nRow)
{
int iRes = 0;
for(int i = 0; i <带中 nRow; i++)
{
_11Images.length = DecodeBase64(Rec.ImgData, _11Images.data, strlen(Rec.ImgData)); //Rec.ImgData为图象数据的base64编码,此处DecodeBase64将Rec.ImgData解码并将结果存_11Images.data。
printf("_11Images.data = %s. _11Images.length = %d. \n", _11Images.data, _11Images.length);
ImgID = Rec.ImageNo;
EXEC SQL INSERT INTO IMAGERESULT VALUES(:ImgID,
printf("EXEC SQL INSERT INTO IMAGERESULT";
if (SQLCODE!=0) { iRes = SQLCODE; break}
}
if (iRes != 0) EXEC SQL ROLLBACK;
else EXEC SQL COMMIT;
return iRes;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询