将字符串转换为BLOB类型数据,写入服务器。
1,首先利用to_clob函数把varchar2字段转成 clob字段。
2 利用c2b上面函数将clob转成blob。
即: c2b(to_clob(varchar2字段))
CREATE OR REPLACE FUNCTION C2B (b IN CLOB default empty_clob()) RETURN BLOB -- typecasts BLOB to CLOB (binary conversion) IS res BLOB; b_len number := dbms_lob.getlength(b) ; dest_offset1 NUMBER := 1; src_offset1 NUMBER := 1; amount_c INTEGER := DBMS_LOB.lobmaxsize; blob_csid NUMBER := DBMS_LOB.default_csid; lang_ctx INTEGER := DBMS_LOB.default_lang_ctx; warning INTEGER; BEGIN if b_len > 0 then DBMS_LOB.createtemporary (res, TRUE); DBMS_LOB.OPEN (res, DBMS_LOB.lob_readwrite); DBMS_LOB.convertToBlob (res, b, amount_c, dest_offset1, src_offset1, blob_csid, lang_ctx, warning ); else select empty_blob() into res from dual ; end if ; RETURN res; -- res is OPEN here END C2B;
示例:
declare bb blob; begin bb := c2b(to_clob(‘abc‘)); dbms_output.put_line(dbms_lob.getlength(bb)); insert into tkk0308 values(2, bb); commit; end;
OK!
问题背景:
一个元数据更新保存功能,经常性的处于卡死状态,有时会出现进一步阻塞其他功能的SQL执行(从数据库端查询阻塞信息时能够确认)。
在应用服务器上抓取dump,确实能够看到应用一直在向数据库写一个lob字段,但是按照常理来说,网络传输应该是很短暂的。
验证方法:
1、在应用服务器上使用sqlplus直接更新一个LOB字段(从应用服务器传输内容),或使简单的控制台程序向数据库更新一个LOB,验证响应时间。
2、让应用服务器绕过防护墙,通过核心交换机直连数据库服务器,做差异对比。
结合应用服务器的dump和数据库端的会话状态、等待事件,应用和数据库间确实是在传输一个LOB字段的内容。当然,按照正常情况下网络传输时间应该很短暂。
请联系客户管理员,确认应用服务器到数据库间是否有企业级防护墙等硬件设备,检查防护墙的配置和日志是否有异常。
SQL:
94 |
17186 |
ACTIVE |
SQL*Net more data from client |
LC0039999 |
WORKGROUP\WIN-DIV4VRINJ9H |
w3wp.exe |
Dump 线程:
OS Thread Id: 0x3e38 (97) Child SP IP Call Site 000000000d8acc78 0000000076f9fefa [NDirectMethodFrameStandalone: 000000000d8acc78] System.Data.Common.UnsafeNativeMethods.OCILobWrite(System.Data.OracleClient.OciHandle, System.Data.OracleClient.OciHandle, System.Data.OracleClient.OciHandle, UInt32 ByRef, UInt32, IntPtr, UInt32, Byte, IntPtr, IntPtr, UInt16, CHARSETFORM) 000000000d8acbf0 000007fef2b0395b DomainNeutralILStubClass.IL_STUB_PInvoke(System.Data.OracleClient.OciHandle, System.Data.OracleClient.OciHandle, System.Data.OracleClient.OciHandle, UInt32 ByRef, UInt32, IntPtr, UInt32, Byte, IntPtr, IntPtr, UInt16, CHARSETFORM)*** WARNING: Unable to verify checksum for System.Data.OracleClient.ni.dll 000000000d8acd30 000007fef2afedfb System.Data.OracleClient.TracedNativeMethods.OCILobWrite(System.Data.OracleClient.OciHandle, System.Data.OracleClient.OciHandle, System.Data.OracleClient.OciHandle, Int32 ByRef, UInt32, IntPtr, UInt32, Byte, UInt16, CHARSETFORM) 000000000d8ace30 000007fef2b2ca45 System.Data.OracleClient.OracleLob.Write(Byte[], Int32, Int32) 000000000d8acf10 000007fef2b1c021 System.Data.OracleClient.OracleParameterBinding.CreateTemporaryLobForValue(System.Data.OracleClient.OracleConnection, System.Data.OracleClient.OracleType, System.Object) 000000000d8acf60 000007fef2b1cb67 System.Data.OracleClient.OracleParameterBinding.PrepareForBind(System.Data.OracleClient.OracleConnection, Int32 ByRef) 000000000d8acfd0 000007fef2b0e1b0 System.Data.OracleClient.OracleCommand.Execute(System.Data.OracleClient.OciStatementHandle, System.Data.CommandBehavior, Boolean, System.Data.OracleClient.OciRowidDescriptor ByRef, System.Collections.ArrayList ByRef) 000000000d8ad0c0 000007fef2b0e7e5 System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean, System.Data.OracleClient.OciRowidDescriptor ByRef) 000000000d8ad150 000007fef2b0e6fd System.Data.OracleClient.OracleCommand.ExecuteNonQuery() 000000000d8ad200 000007ff001eee35 Genersoft.Platform.Core.DataAccess.Database.ExecuteWithNoQuery(System.String, System.Data.IDbDataParameter[], Boolean)*** ERROR: Module load completed but symbols could not be loaded for Genersoft.Platform.Core.DataAccess.dll 000000000d8ad2b0 000007ff00c7dbb9 Genersoft.Platform.Core.DataAccess.Database.RunProcWithNoQuery(System.String, System.Data.IDbDataParameter[]) 000000000d8ad300 000007ff00c7d787 Genersoft.Platform.Resource.ResourceManager.DataModelManager.SaveModel(Genersoft.Platform.Resource.Metadata.DataModel.GspDataModel)*** ERROR: Module load completed but symbols could not be loaded for Genersoft.Platform.Resource.DataModelManager.dll 000000000d8ad3f0 000007ff00c7d168 Genersoft.Platform.Resource.ResourceManager.DataModelManager.SaveModelAllInfor(Genersoft.Platform.Resource.Metadata.DataModel.GspDataModel) 000000000d8ad430 000007ff00c7c120 Genersoft.Platform.Resource.ResourceManager.MetadataService.SaveAndCheckInMetadata(System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.DateTime, Genersoft.Platform.Resource.Metadata.IMetadataContent, System.String)*** ERROR: Module load completed but symbols could not be loaded for Genersoft.Platform.Resource.MetadataManager.dll 000000000d8ad600 000007ff00c73dd0 Genersoft.Platform.RuntimeADP.Core.Manager.GSPBizEntityManager.SaveBizEntity(Genersoft.Platform.RuntimeADP.SPI.IBusinessEntity, Boolean, Genersoft.Platform.RuntimeADP.SPI.BizUnitAssignment, Boolean, Boolean ByRef, System.Collections.Generic.Dictionary`2<System.String,Genersoft.Platform.Resource.Metadata.DataObject.GspDataTable>)*** WARNING: Unable to verify checksum for Genersoft.Platform.RuntimeADP.Core.dll *** ERROR: Module load completed but symbols could not be loaded for Genersoft.Platform.RuntimeADP.Core.dll 000000000d8ad7b0 000007ff00b8f92a Genersoft.Platform.RuntimeADP.Core.Manager.GSPBizEntityManager.AddBizEntity(Genersoft.Platform.RuntimeADP.SPI.IBusinessEntity, Genersoft.Platform.RuntimeADP.SPI.BizUnitAssignment, Boolean ByRef) 000000000d8ad8b0 000007ff00b8f4d8 Genersoft.Platform.RuntimeADP.Core.Manager.GSPBizEntityManager.AddBizEntity(Genersoft.Platform.RuntimeADP.SPI.IBusinessEntity, Genersoft.Platform.RuntimeADP.SPI.BizUnitAssignment) 000000000d8ad8f0 000007ff00b85894 Genersoft.HR.Sys.RunTimeCore.Manager.HRSalaryRuntimeManager.SubSetSynchronization(System.String, System.String, System.String, System.Collections.Generic.List`1<Genersoft.HR.Sys.Spi.HRWriteBackFieldMapping>, System.String)*** WARNING: Unable to verify checksum for Genersoft.HR.Sys.RunTimeCore.dll *** ERROR: Module load completed but symbols could not be loaded for Genersoft.HR.Sys.RunTimeCore.dll 000000000d8adb30 000007ff00b84a4f Genersoft.HR.Sys.RunTimeCore.Manager.HRSalaryRuntimeManager.SubSetSynchronization(System.String) 000000000d8ae328 000007fef95a10b4 [DebuggerU2MCatchHandlerFrame: 000000000d8ae328] 000000000d8ae410 000007fef95a10b4 [CustomGCFrame: 000000000d8ae410] 000000000d8ae3d8 000007fef95a10b4 [GCFrame: 000000000d8ae3d8] 000000000d8ae368 000007fef95a10b4 [GCFrame: 000000000d8ae368] 000000000d8ae738 000007fef95a10b4 [HelperMethodFrame_PROTECTOBJ: 000000000d8ae738] System.RuntimeMethodHandle._InvokeMethodFast(System.IRuntimeMethodInfo, System.Object, System.Object[], System.SignatureStruct ByRef, System.Reflection.MethodAttributes, System.RuntimeType) 000000000d8ae880 000007fef865587f System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, Boolean) 000000000d8ae9c0 000007fef86a0426 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) 000000000d8aea10 000007ff005635a5 Genersoft.Platform.AppFramework.Service.GSPRestfulContext.Invoke(System.String, System.String, System.String, Boolean, System.String[], Int32[] ByRef, System.String[] ByRef)*** ERROR: Module load completed but symbols could not be loaded for Genersoft.Platform.AppFramework.RestfulService.dll 000000000d8aead0 000007ff00563174 Genersoft.Platform.AppFramework.RESTFulWebService.GSPHttpWebHandler.Invoke(System.IO.BinaryReader, System.Web.HttpContext)*** ERROR: Module load completed but symbols could not be loaded for Genersoft.Platform.AppFramework.RESTFulWebService.dll 000000000d8aebd0 000007ff001efc76 Genersoft.Platform.AppFramework.RESTFulWebService.GSPHttpWebHandler.ProcessRequest(System.Web.HttpContext) 000000000d8aecd0 000007fef3625c25 System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()*** WARNING: Unable to verify checksum for System.Web.ni.dll 000000000d8aed90 000007fef35f337a System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 000000000d8aee40 000007fef3607030 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception) 000000000d8aef00 000007fef35f2879 System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object) 000000000d8aef60 000007fef35f777c System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest) 000000000d8aefe0 000007fef35f6477 System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32) 000000000d8af110 000007fef3d5d6dd DomainNeutralILStubClass.IL_STUB_COMtoCLR(Int64, Int32, Int32 ByRef) 000000000d8af448 000007fef960e93e [GCFrame: 000000000d8af448] 000000000d8af488 000007fef960e93e [ContextTransitionFrame: 000000000d8af488] 000000000d8af4c8 000007fef960e93e [GCFrame: 000000000d8af4c8] 000000000d8af6b0 000007fef960e93e [ComMethodFrame: 000000000d8af6b0]
时间: 2024-10-10 23:12:18