Pascal Data Objects


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)
        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;


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

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

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;


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
            row: array of TPDORowNative;
            property  RowCount: Int64 Read FRows;

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;

Both TPDORowNative and TPDORowSetNative objects must be instanciated and freed.