ORA-01460:未实现或不合理的转换请求blob插入 [英] ORA-01460: unimplemented or unreasonable conversion requested blob insert

查看:130
本文介绍了ORA-01460:未实现或不合理的转换请求blob插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在尝试将blob插入数据库。为此我使用的是c ++和microsoft ODBC驱动程序。



该应用程序适用于少于4000字节的文件。当我试图插入一个超过4000字节的文件,意味着3.9 KB它返回:ORA-01460:请求未实现或不合理的转换。



数据库是oracle 11.2.0。我搜索了国际内部的解决方案,但没有找到。



我怎么能解决这个问题?我该怎么办?



我的插入功能的代码是:



Hello,

I am trying to insert an blob into a database . For this I am using c++ and microsoft ODBC driver.

The app works fine with files that have less than 4000 bytes. When i am trying to insert a file that has more than 4000 bytes , meaning 3.9 KB it returns : ORA-01460: unimplemented or unreasonable conversion requested .

The database is oracle 11.2.0 . I have searched the internat for a solution but find none .

How could i solve this problem ? What can i do ?

The code for my insert function is :

try{
		CString strSqlStat(szSqlStat);

		if(IsConnectionDead())
		{
			if(!Reconnect())
				return ERR_RECONNECT_FAILED;
		}

		CFileException exFile;
		CFile sourceFile;
		if(!sourceFile.Open(szFilePath, CFile::modeRead | CFile::shareDenyNone, &exFile))
			return ERR_BLOB_READFILE;

		int nrBytesToRead = (int)sourceFile.GetLength();
		char* pData = new char[nrBytesToRead+1];

		DWORD nrBytesRead;

		if(!ReadFile((HANDLE)sourceFile.m_hFile,pData,nrBytesToRead, &nrBytesRead, NULL))
		{
			delete pData;
			return ERR_BLOB_READFILE;
		}

		sourceFile.Close();

		if(nrBytesRead == 0)//file empty
		{
			delete pData;
			return 0;
		}

		//variables
		SQLRETURN retCode; 
		SDWORD   cbTextSize, lbytes;
		lbytes = (SDWORD)nrBytesRead;
		cbTextSize = SQL_LEN_DATA_AT_EXEC(lbytes);
		PTR pParmID;
		SDWORD cbBatch = nrBytesRead;
		int rgbValue = 1;

		// Bind the parameter marker.
		retCode = retcode = SQLBindParameter(hstmt,  // hstmt
			 1,                     // ipar
			 SQL_PARAM_INPUT,            // fParamType
			 SQL_C_BINARY,               // fCType
			 SQL_LONGVARBINARY,           // FSqlType
			 lbytes,                  // cbColDef
			 0,                     // ibScale
			 &rgbValue,       // rgbValue
			 0,                     // cbValueMax
			 &cbTextSize);            // pcbValue

		SqlError(hstmt,SQL_HANDLE_STMT,_T("WriteBlob"), _T("CTLSqlConnection"), _T("SQLBindParameter"));
		if(retCode != SQL_SUCCESS)
		{
			delete pData;

			if(!EndTransaction(FALSE))
				return ERR_ENDTRANSACTION_FAILED;
			else
				return -3;
		}

		//SQLExec		
		retcode = retCode = SQLExecDirect(hstmt,(SQLTCHAR*)szSqlStat, SQL_NTS);
		retcode = retCode = SQLParamData(hstmt, &pParmID);
			SQLRETURN ret; //ADI fix all warnings - including this var that is unreferenced - delete it if you don't use it
			SQLCHAR* SQLState; //ADI same here
			SQLINTEGER NativeError;
			SQLSMALLINT errmsglen;
			SQLWCHAR errmsg[255];
			SQLWCHAR errstate[50];
			
	
	SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, 1, (SQLWCHAR*)errstate, &NativeError, (SQLWCHAR*)errmsg, sizeof(errmsg), &errmsglen);
	
	
		if(retCode == SQL_NEED_DATA)
		{
			// Put final batch.
			SQLPutData(hstmt, pData, lbytes); 
		}
		else
		{
			delete pData;

			SqlError(hstmt,SQL_HANDLE_STMT,_T("WriteBlob"), _T("CTLSqlConnection"), _T("SQLExecDirect or SQLParamData"));
			if(!EndTransaction(FALSE))
				return ERR_ENDTRANSACTION_FAILED;
			else
				return -4;
		}

		delete pData;

		// Make final SQLParamData call.
		retcode = retCode = SQLParamData(hstmt, &pParmID);
		/*SQLRETURN ret; //ADI fix all warnings - including this var that is unreferenced - delete it if you don't use it
			SQLCHAR* SQLState; //ADI same here
			SQLINTEGER NativeError;
			SQLSMALLINT errmsglen;
			SQLWCHAR errmsg[255];
			SQLWCHAR errstate[50];
		*/	
	
	SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, 1, (SQLWCHAR*)errstate, &NativeError, (SQLWCHAR*)errmsg, sizeof(errmsg), &errmsglen);

		if(SqlError(hstmt,SQL_HANDLE_STMT,_T("WriteBlob"), _T("CTLSqlConnection"), _T("The last SQLParamData")))
			if(!EndTransaction(FALSE))
				return ERR_ENDTRANSACTION_FAILED;
			else
				return -5;
		
		retcode = SQLCloseCursor(hstmt);
	
		if(!EndTransaction(TRUE))
			return ERR_ENDTRANSACTION_FAILED;
			
	}catch(...){
		WRITEERRORINLOGFILE(_T("Error: An exception has been caught in WriteBlob."));
		return -10;
	}

   return 0;

}





我找不到任何解释为什么它不能用于大文件。



我该如何解决这个问题?

坦克为您提供帮助。



I could not find any explanation why it is not not working for large files.

How could I solve the problem ?
Tanks for your help.

推荐答案

http://www.dba-oracle.com/t_bigfile_tablespace_tips.htm [ ^ ]


After investigating and reflecting into the code I found that by changing the Direction of the Parameter to input output - the problem was resolved.

p.Direction = ParameterDirection.InputOutput;


这篇关于ORA-01460:未实现或不合理的转换请求blob插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆