嵌入式sql怎么向包含blob字段表insert数据
1个回答
2014-12-23
展开全部
您好,我在别的论坛也看到您的问题,很高兴为您解答:
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;
}
如果我的回答没能帮助您,请继续追问。转载,仅供参考。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询