Use BLOB and CLOB data types
nxyc_twz@163.com
The ODAC component supports the BLOB and CLOB data types of Oracle 8. You can use the ToraQuery component to get the value of the LOB field, use the same method, you can also get the long or long row field. When you need to use SQL DML and PL / SQL statements to access these fields, you will find that the usage of the LOB data type is significantly different. BLOB and Clob Data Types are stored in the table column via the LOB locator (specified data address); the actual BLOB and Clob data are stored in a separate table space. In contrast, the LONG or Long Raw type is stored in the database, and their actual values are stored in the table. When accessing the LOB column, returns the locator without returning its actual value as a long or long RAW data type. For example, analyze the definition of this table: CREATE TABLE CLOBTABLE (ID Number, Name VARCHAR2 (30), Value Clob) If we do not pass the value parameter, Oracle will not allow the following statement to update the data table: Update ClobtableSetName =: Name, value =: valuewhereId =: ID To initialize the LOB locator, you must use the Empty_Blob or Empty_Clob Oracle function. To return to the initialized positioner, use the ReturNing clause in the same statement. For example: Update ClobTableSetName =: name, value = Empty_clob () whereid =: idReturnngu ValueInto: valueodac write LOB data to Oracle and returns the initial value field, you need to use: value parameters. Stored procedures allow automatic initialization LOB values, as follows: CREATE OR REPLACEPROCEDURE ClobTableUpdate (p_Id NUMBER, p_Name VARCHAR2, p_Value OUT CLOB) isbeginUPDATE ClobTableSET Name = p_Name, Value = EMPTY_CLOB () WHEREId = p_IdRETURNINGValueINTOp_Value; end; Note: The value of the parameter is declared as OUT. At the same time, the parameters of the parameter for setting the LOB data type are PTINPUT, and specify it to the desired data to actually call the stored procedure. We can call a stored procedure previously declared: OraStroredProc1.StoredProcName: = 'ClobTableUpdate'; OraStroredProc1.Prepare; OraStroredProc1.ParamByName ( 'p_Id') AsInteger:.. = Id; OraStroredProc1.ParamByName ( 'p_Name') AsString: = Name ; OraStroredProc1.ParamByName ( 'Value') ParamType:. = ptInput; OraStroredProc1.ParamByName ( 'Value') AsCLOBLocator.LoadFromFile (FileName); OraStroredProc1.Execute; for ODAC, it is very important to use the property in the LOB ParamType operation. of.