Example - Selecting a reference

Top  Previous  Next

次のサンプルは、Parsonsオブジェクトテーブルからリファレンスカラム(Mother)を選択し、リファレンスがnullかどうかを調べ、リファレンスをPinして、そしてリファレンスされたTpersonオブジェクトの名前を表示します:

var Mother: TOracleObject;

     RefMother: TOracleReference;

begin

   Query.SQL.Text := 'select Name, Mother from Persons';

   Query.Execute;

   while not Query.Eof do

   begin

     RefMother := Query.RefField('Mother');

     if not RefMother.IsNull then

     begin

       Mother := RefMother.Pin(poAny, plNone);

       ShowMessage('The mother of ' + Query.Field('Name') + ' = ' + Mother.GetAttr('Name'));

       Mother.Free;

     end;

     Query.Next;

   end;

end;