 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Pete Wason Guest
|
Posted: Thu Jul 15, 2004 12:28 pm Post subject: ClientDatasets question (general db question) |
|
|
Hiall!
I'm writing a small app for a client which among other things has three
datasets artists, recordings and reviews. Recordings and reviews have an
integer ArtistID field, and reviews has an integer RecordingID field. I'm using
dbcombolookup controls to show/pick data for Artist and Recording. The client
wants to be able to sort recordings by Issue (an integer field in reviews) and
by Artist, or just by Artist.
I'm trying to figure out how to do this. Any help will be greatly appreciated.
TIA!
Pete
[email]codevark (AT) netscape (DOT) net[/email]
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Thu Jul 15, 2004 1:18 pm Post subject: Re: ClientDatasets question (general db question) |
|
|
Use a SELECT statement that joins the three tables and orders by
Issue.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Pete Wason Guest
|
Posted: Fri Jul 16, 2004 11:46 am Post subject: Re: ClientDatasets question (general db question) |
|
|
Bill Todd (TeamB) wrote:
| Quote: | Use a SELECT statement that joins the three tables and orders by
Issue.
|
well, list that would be great except that TClientDatasets don't deal with
SQL, unless the various texts I'm reading are misleading me. If I can in fact
use SQL statements with these datasets, the path is clear. Otherwise I might
have to add another dataset or something...
Pete
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Fri Jul 16, 2004 2:00 pm Post subject: Re: ClientDatasets question (general db question) |
|
|
The word "TClientDataSet" does not appear anywhere in your original
message. What else are you not telling us about what your are trying
to do? :)
You cannot sort a CDS on a field that is not part of the CDS. You
might be able to use and internal calculated field to get the value to
sort by.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Ed Guest
|
Posted: Fri Jul 16, 2004 2:28 pm Post subject: Re: ClientDatasets question (general db question) |
|
|
Bill Todd (TeamB) wrote:
| Quote: | The word "TClientDataSet" does not appear anywhere in your original
message.
|
and what about the title ??
|
|
| Back to top |
|
 |
Pete Wason Guest
|
Posted: Mon Jul 19, 2004 2:14 am Post subject: Re: ClientDatasets question (general db question) |
|
|
Bill Todd (TeamB) wrote:
| Quote: | The word "TClientDataSet" does not appear anywhere in your original
message. What else are you not telling us about what your are trying
to do? :)
You cannot sort a CDS on a field that is not part of the CDS. You
might be able to use and internal calculated field to get the value to
sort by.
|
Sorry, I thought the subject of "ClientDataset question" would have been enough
to identify the type of component I'm using. Excuse my brevity.
I've reread the D5 Developer's Guide regarding ClientDatasets, but am not
seeing clearly how to do this thing. I thought about having a "filter by issue
number" dropdown that would be populated with unique issue numbers from
reviews, but even with that, what would my next step be? Would my problem be
less thorny if there were a clear master-detail relationship here? Apparently,
according to the client, no recording will ever appear in multiple issues or
reviews, but I hesitate to design data relationships on this assumption.
The tables look something like this:
Artists
ID
Name
etc.
Recordings
ID
Name
ArtistID
Image1File
Image2File
Image3File
Reviews
ID
Title
RecordingID
ArtistID
Issue
etc.
Obviously, Artists <--> Recordings is a one-to-many relationship. Reviews <-->
Artist+Recording is a one-to-one relationship (apparently). I suppose I could
1. use the dropdown described above
2. filter Reviews for the chosen issue number
3. iterate over Reviews and build a (possibly lengthy) filter expression made
up of all the RecordingIDs
4. apply this new filter to the Recordings dataset to show only Recordings
reviewed in the chosen issue.
or maybe it's just too late, and there's a much simpler way of doing this that
I'm not seeing right now...
yawn. tfrm.
Pete
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Mon Jul 19, 2004 5:52 pm Post subject: Re: ClientDatasets question (general db question) |
|
|
| Quote: | Sorry, I thought the subject of "ClientDataset question" would have been enough
to identify the type of component I'm using. Excuse my brevity.
|
You are right. I certainly should have seen that.
| Quote: |
I've reread the D5 Developer's Guide regarding ClientDatasets, but am not
|
It is always a good idea to include the version of Delphi and any
other software in your message when you are not using the current
version. If you don't give the version everyone will assume D7 and
that could lead to an inappropriate answer.
| Quote: | seeing clearly how to do this thing. I thought about having a "filter by issue
number" dropdown that would be populated with unique issue numbers from
reviews, but even with that, what would my next step be? Would my problem be
|
The two obvious ways are to use a join in your SELECT statement that
includes the issue number in the result set. That way you can sort on
it just as you do with other fields in the CDS. If you do this you
will need to set the pfInUpdate provider flag for the issue number
field object to false and write an OnGetTableName event handler for
the DSP to return the name of the table to update.
The only other method that occurs to me is to use an internal
calculated field to get the issue number, however, I would use the
join.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Pete Wason Guest
|
Posted: Mon Jul 19, 2004 7:17 pm Post subject: Re: ClientDatasets question (general db question) |
|
|
Bill Todd (TeamB) wrote:
| Quote: | Sorry, I thought the subject of "ClientDataset question" would have been enough
to identify the type of component I'm using. Excuse my brevity.
You are right. I certainly should have seen that.
I've reread the D5 Developer's Guide regarding ClientDatasets, but am not
It is always a good idea to include the version of Delphi and any
other software in your message when you are not using the current
version. If you don't give the version everyone will assume D7 and
that could lead to an inappropriate answer.
seeing clearly how to do this thing. I thought about having a "filter by issue
number" dropdown that would be populated with unique issue numbers from
reviews, but even with that, what would my next step be? Would my problem be
The two obvious ways are to use a join in your SELECT statement that
includes the issue number in the result set. That way you can sort on
it just as you do with other fields in the CDS. If you do this you
will need to set the pfInUpdate provider flag for the issue number
field object to false and write an OnGetTableName event handler for
the DSP to return the name of the table to update.
The only other method that occurs to me is to use an internal
calculated field to get the issue number, however, I would use the
join.
|
umm... so I *can* use SQL with CDS? I was under the impression I had to do
everything with filters, ranges and the like. If I can use SQL, then the join
idea is obviously easy (and easily obvious). I'm not sure where I read that I
couldn't use SQL, but it stuck in my head for some reason. And I'm using D6,
BTW; I just have the D5 book to work with as most of my previous work was in D5.
Thanks!
Pete
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Mon Jul 19, 2004 7:36 pm Post subject: Re: ClientDatasets question (general db question) |
|
|
On Mon, 19 Jul 2004 15:17:27 -0400, Pete Wason <Codevark (AT) netscape (DOT) net>
wrote:
| Quote: | umm... so I *can* use SQL with CDS? I was under the impression I had to do
everything with filters, ranges and the like. If I can use SQL, then the join
idea is obviously easy (and easily obvious). I'm not sure where I read that I
couldn't use SQL, but it stuck in my head for some reason. And I'm using D6,
BTW; I just have the D5 book to work with as most of my previous work was in D5.
|
Sorry. I forgot that you are using the CDS as the database and are not
connected to a database through a DSP. The only way I can think of to
do what you want in that environment is to use an internal calculated
field to get the issue number from the other CDS and sort on the
internal calculated field. I have never tried that but it should work.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Pete Wason Guest
|
Posted: Tue Jul 20, 2004 9:36 pm Post subject: Re: ClientDatasets question (general db question) |
|
|
Bill Todd (TeamB) wrote:
| Quote: | On Mon, 19 Jul 2004 15:17:27 -0400, Pete Wason
wrote:
umm... so I *can* use SQL with CDS? I was under the impression I had to do
everything with filters, ranges and the like. If I can use SQL, then the join
idea is obviously easy (and easily obvious). I'm not sure where I read that I
couldn't use SQL, but it stuck in my head for some reason. And I'm using D6,
BTW; I just have the D5 book to work with as most of my previous work was in D5.
Sorry. I forgot that you are using the CDS as the database and are not
connected to a database through a DSP. The only way I can think of to
do what you want in that environment is to use an internal calculated
field to get the issue number from the other CDS and sort on the
internal calculated field. I have never tried that but it should work.
|
Thanks! I'll try it and report my findings to the group.
;-)
Pete
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|