Hi All,
Funny the subject should come up again... Well, when one is developing just
what is being asked about ("Why isn't there something that does ________?"
as per the recent discussion on DmWrite), it is tempting to chime in. I know
this forum is not intended for product plugs, and this is not intended as
one, but only informational since this product is still "vaporware"
(unreleased).
I previously wrote about a small PalmOS database engine we are developing
for primarily our own application use. Thanks to several developers who
replied and expressed interest in beta testing, we are planning on polishing
the thing up to hopefully stand on its own as a reusable development
component.
Basically DBQuick does record management, abstraction, and all the packing
and unpacking of fields for you, and it stores data the same efficient way
you
would likely do it by writing custom code (i.e. packed strings, etc.). The
tables are abstracted to work more like files, and each file is also
self-describing. Instead of writing custom code to pack and unpack fields
into records, you do something much like the following:
DBQ_DBRef rDBQ; // this is our handle to a database table
rDBQ = DBQ_Open("Assets_Smpl", false); // try to open the Assets table for
the Smpl app
// "Assets_Smpl" is the database name, "Asse" is the type, and "Smpl" is the
creator/owner
if (!rDBQ) // didn't open?
{
rDBQ = DBQ_Create("Assets_Smpl", 3); // create new table containing
three fields
if (rDBQ)
{
DBQ_NewField(rDBQ, 0, "Location", DBQ_TypeString, 3);
DBQ_NewField(rDBQ, 1, "Part", DBQ_TypeString, 8);
DBQ_NewField(rDBQ, 2, "BarCode", DBQ_TypeString, 12);
DBQ_UpdateHeader(rDBQ); // commit the file structure
}
}
// now we should have opened an existing table or created it fresh
if (rDBQ)
{
// wire the "fields" to members of a handy global struct
DBQ_AssociateField(rDBQ, "Location", Asset.szLocation);
DBQ_AssociateField(rDBQ, "Part", Asset.szPart);
DBQ_AssociateField(rDBQ, "BarCode", Asset.szBarCode);
}
// now our table is open and ready to work on...
// ... here's some code that adds a new record, for example:
DBQ_NewRecord(rDBQ); // start a new record
StrCopy(Asset.szLocation, "SEA"); // stuff data into global struct
StrCopy(Asset.szPart, "FRAMA-42");
StrCopy(Asset.szBarCode, "8675309");
DBQ_UpdateRecord(rDBQ); // save the record
// ... now let's seek to record 42, and maybe change it
DBQ_Seek(rDBQ, 42, DBQ_SEEKFIRST); // can also see from current or end
// after seeking, the global struct we wired up earlier is automagically
loaded
// with the record data
if (0 == StrCompare(Asset.szLocation, "LAX")) // is field Location =
"LAX"?
{
StrCopy(Asset.szPart, "NONE"); // change Part field to "NONE"
DBQ_UpdateRecord(rDBQ); // update the record
}
There are functions for retrieving the current record position, EOF
condition, count, deleting records, and very soon-to-be-implemented: primary
index field and quick finds on that field. In addition to string fields, it
also supports Integer and Boolean field types with room for more.
Performance thus far has been extremely encouraging (knock on bits). For
example, in our application one can fluidly scroll up and down through
thousands of records (9 fields each record). The only slow-down is in actual
record creation which seems to take slightly longer and longer the more
records there are in the database. I've thought about storing more than one
database record per PalmOS database record which would offer tremendous
gains for synch times for very large tables, but at the cost of complexity
in the PalmOS-specific database layer. However, such an optimization would
be transparent to an application using DBQuick.
I wish it was ready for folks to use now, as the need is there. I'll get
back to those who asked about beta testing very shortly, though! Thanks for
your interest and patience.
--
Geoff Shepherd
[EMAIL PROTECTED]
> At 12:21 PM 5/18/99 -0700, Steve Mann wrote:
> >>and have the packing/unpacking taken care of? Is this even possible? It
seems
> >>that re-inventing the wheel for ever application is silly if there's a
generic
> >>way to do it.