Pascal Data Objects

IPDOResult

A variable of type IPDOResult can return a value cast as almost any data type. If the "value" property is used, the variant return will be of the type defined by the database structure. If the database field can be null, the boolean "null" property can be used to test for it. The rest of the IDPOResult methods typecast the store value.

    IPDOResult = interface(IInterface)
    ['{395692A4-4149-44E1-A58B-1A30DAACFEB3}']
        function getValue:        Variant;
        function getNull:         Boolean;
        property value:           Variant READ getValue;
        property null:            Boolean READ getNull;
        function asString:        AnsiString;
        function asUnicodeString: WideString;
        function asPChar:         PChar;
        function asByte:          Byte;
        function asShortInt:      ShortInt;
        function asWord:          Word;
        function asSmallInt:      SmallInt;
        function asLongWord:      LongWord;
        function asCardinal:      Cardinal;
        function asLongInt:       LongInt;
        function asInteger:       Integer;
        function asInt64:         Int64;
        function asSingle:        Single;
        function asDouble:        Double;
        function asExtended:      Extended;
        function asBoolean:       Boolean;
        function asDate:          TDateTime;
        function asTime:          TDateTime;
        function asTimestamp:     TDateTime;
        function asAsciiStream:   TStream;
        function asBytes:         TByteDynArray;
    end;

TPDORowNative

The TPDORowNative object is a dynamic array of IPDOResult variables. The "public" part of the object is as follows:

    TPDORowNative = class
        public
            column: array of IPDOResult;
            function hash (Key: Ansistring): IPDOResult;
            property ColumnCount: Byte Read FColumns;
    end;

Use the ColumnCount property to determine how many columns are returned in the result if this is not already known. The "hash" function allows access to the field data by the column name. The field data can also be referenced by the column index. Here are some examples:

   myString  := row.column[2].asString;
   myWord    := row.hash('students').asWord;
   myBoolean := row.column[0].asBoolean;
   myDouble  := row.hash('test_average').asDouble;
   myInteger := row.hash('number_touchdowns').value;

TPDORowSetNative

This structure is an object that is essentially a dynamic array of TPDORowNative objects. The TPDO.fetch_all method can return an entire result set and place it into this structure. The "public" part of the object is as follows:

    TPDORowSetNative = class
        public
            row: array of TPDORowNative;
            property  RowCount: Int64 Read FRows;
    end;

You might access some set data like this:

   myWord   := rowset.row[3].column[3].value;
   myString := rowset.row[22].hash('student_name').asString;
   with rowset.row[13] do begin
       myByte := column[1].asByte;
       myInteger := column[2].asInteger;
       myBoolean := hash('married').asBoolean;
   end; 

Both TPDORowNative and TPDORowSetNative objects must be instanciated and freed.