ODAC Usage Tips (4) Use Varray Data Types

zhaozj2021-02-16  46

ODAC Usage Tips (4) Use Varray Data Types

nxyc_twz@163.com

Recommended an array when using an object. But there may be some problems when you need to use large numbers in the data set. For example, when you create a large number of arrays for a field of ODAC, a large number of TFIELD fields can result in the performance of the program. Therefore, ODAC restrictions can only create 1000 members for fields. But no matter what, you can use the ToraArray object to access all members. Of course, you can also be implemented by other methods. For example, set ToraQuery.sparsearray to TRUE and access array members through the TarrayField object. If the following types created: CREATE TYPE TODACArray1 AS VARRAY (5) OF NUMBER; CREATE TYPE TODACArray2 AS VARRAY (4) OF CHAR (10); CREATE TABLE ODAC_Array (Code NUMBER, Title VARCHAR2 (10), Arr1 TODACArray1, Arr2 TODACArray2 ,); To access array members, you need to call the method FieldbyName. For example: value: = query.fieldbyName ('Arr1 [0]'). Asinteger; if Objectfield Property is true this code is rightvalue: = tarrayfield ('arr1')). Fields [0] .asinteger; using, for example, query.fieldbyname ToraDataSet.GetArray You CAN Access To Array Items Through Torarray ObjectValue: = query.GetArray ('Arr1'). Itemsinteger [0]; You can use the Varray type as a parameter in SQL and PL / SQL statements. You need to specify DTARRAY to ToraParam.DataType and use the ToraParam.ASARRAY attribute to access array members.

For example: VaroraSQL: ToraSQL ;... Orsql.sql.text: = 'INSERT INTO ODAC_ARRAY (CODE, Arr1, Arr2)' 'VALUES (: Code,: Arr1,: Arr2); ORASQL.Parambyname (' Code ' ) .Asinteger: = 10; with oracaql.Parambyname ('Arr1'). AsaRray do BeginalLocObject (ORASESSION.OCISVCCTX, 'TodacarRay1'); itemasinteger [0]: = 12; Attrasinteger ['[1]']: = 10; ItemAsInteger [3]: = 133; end; with OraSQL ParamByName ( 'Arr2') asArray do beginOCISvcCtx:.. = OraSession.OCISvcCtx; AllocObject ( 'TODACArray2'); AttrAsString [ '[2]']: = 'eeee'; Itemstring [0]: = 'fffff'; end; orachen.execute;

转载请注明原文地址:https://www.9cbs.com/read-26416.html

New Post(0)