I have been doing more QuickBase work lately. I really like QuickBase but the HTTP API can be a bit hairy. Intuit provides various language specific SDKs for the QuickBase API but Delphi is not included. So I'm writing my own. [I'll post the code to the White Peak Software site as soon as it is done.]

A challenge I encounter today was determining an appropriate data structure for a QuickBase record set. The QuickBase API includes a DoQuery call that returns an XML document containing the results of the query. A goal of my Delphi QuickBase SDK is to simplify API calls such as DoQuery, which means I do not want to return XML to calling Delphi code. A Delphi friendly data structure for the QuickBase record set is needed.

After bouncing different ideas around a buddy, I started "seeing" the data structure. I started hacking up code keeping in mind 3 primary goals:

1) The data structure must be easy to use.
2) The data structure must make the code readable.
3) The data structure must be Delphi friendly.

The end result is a set of classes which is really nothing more than a TObjectList containing TObjectList containing a field value class. In other words, the final data structure consists of the following classes:

TQuickBaseDataset = class(TObjectList);
TQuickBaseRecordset = class(TObjectList);
TQuickBaseValue = class(TObject);

A dataset contains one or more record sets which contains one of more values. The value class is implemented to provide strong type access to the value returned from QuickBase.

So does the new data structure meet the 3 goals above? I think so but I will leave it up to you to decide. Here is a code snippet that queries the database and returns a record set containing 3 fields in each record.

Qdb := TQuickBaseClient.Create(username, password);
if Qdb.Authenticate then
begin
Dataset := Qdb.DoQuery(dbid, query, clist);
for Recordset in Dataset do
begin
s := Recordset.Items[0].ValueAsString;
b := Recordset.Items[1].ValueAsBoolean;
i := Recordset.Items[2].ValueAsInteger;
end;
end;
Qdb.SignOut;
Qdb.Free;

I will be adding the ability to retrieve field values by name very soon. This will make the code even more readable.

posted by Kirby | 15-Jun-2006 3:40 AM | comments (2)


Do you know about the Ruby API? - http://raa.ruby-lang.org/project/quickbase/

posted by | June 16 10:59 PM


Nice. I didn't know about it. I'll take a look at it.

posted by Kirby Turner | June 17 05:54 AM

Add Your Comment

Comment:
(No HTML)

Name:
E-mail/Web site:
Your e-mail/web site will not be published on this site. It is optional and will only be used by me should I need to contact you directly.
 
By checking this option, this site will remember your name and e-mail/web site on future visits. Uncheck this option to have the site not remember who you are on future visits.
 
Enter the code shown above:
Copyright © 1999-2008 Kirby Turner.
Site software written by White Peak Software Inc, a provider of custom software and software development coaching.