Board index » delphi » Not sure if it's a bug?

Not sure if it's a bug?

Quote
Hayk Petrosyan wrote:

> Hi,

> I have a very interesting situation.

> Let's say I have 2 tables

> Table1
> Key
> Name
> Rent

> Table2
> Key
> Source
> Rent

> and I am using following SQL statement

> select T1.Name, T2.Rent
> from Table1 T1, Table2 T2
> where T2.Key = T1.Key

> and it works just fine. But when I am adding "order by Rent" it acts pritty
> strange. Even though I specified that I am using T2.Rent it will actually
> sort by T1.Rent

Not a bug.  Order by columns do not have to be in the select portion (unlike
Oracle IIRC).  This means you've given an ambiguous column to order on and IB
picks the first table in the from clause.

Quote
> It wouldn't be a problem if I were using custom Queries for everythin I
> need, but I have a standard code which's automaticly sorts when user clikcs
> on Grid Header and at that moment I know only Field Name and not Table name
> to sort.

The TField's Origin should be in the format of table.field.

Quote
> Anyway, is it a bug or I am doing something wrong?

> Thanks!
> Hayk

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
The correct way to punctuate a sentence that starts: "Of course it is
none of my business but ~" is to place a period after the word "but".
Don't use excessive force in supplying such a moron with a period.
Cutting his throat is only a momentary pleasure and is bound to get
you talked about.   (RAH)
 

Re:Not sure if it's a bug?


Quote
Hayk Petrosyan wrote:

> Jeff,

> This is what is says in Help about Origin

> Origin is only assigned at design time by the Fields editor, and only when
> the field component is used by a TQuery object.

IBX does it both at design time and run time.  It always fills out the origin.

Quote
> Does it mean that I have to go through each and every field and assign it
> myself manually at dessing time?

> Hayk

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
The correct way to punctuate a sentence that starts: "Of course it is
none of my business but ~" is to place a period after the word "but".
Don't use excessive force in supplying such a moron with a period.
Cutting his throat is only a momentary pleasure and is bound to get
you talked about.   (RAH)

Re:Not sure if it's a bug?


Quote
Jeff Overcash (TeamB) wrote:
> IBX does it both at design time and run time.  It always fills out
> the origin.

Sorry, to inform you, Jeff, but when design time fields are created,
rintime their Origin is not filled.
So it works only design time.

--
Bojidar Alexanrov
Kodar Ltd.
http://www.Kodar.net

Re:Not sure if it's a bug?


Quote
Bojidar Alexandrov wrote:

> Jeff Overcash (TeamB) wrote:
> > You are mistaken.  This code

> > procedure TForm1.Button1Click(Sender: TObject);
> > begin
> >   IBDataSet1.Close;
> >   IBDataSet1.SelectSQL.Text := 'select * from employee';
> >   IBDataSet1.Open;
> >   ShowMessage(IBDataset1.FieldByName('dept_no').Origin);
> > end;

> > Correctly displays EMPLOYEE.DEPT_NO.  You must not be on a current
> > version of IBX, but this was put in nearly a year ago IIRC.  If you
> > are persisting TFIelds at design time the Origin won't change
> > (nothing changes).

> Your example is correct, but I have said about the case when teh fields are
> created design time ie persistent fields, note this in my post.

Persisted TFields never change their values.  That is the whole point in
persisting them at design time.  The Origin is also filled out when persisting
them at design time.  Once persisted though the TField values set are never
changed unless you explicitly do so.

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
The correct way to punctuate a sentence that starts: "Of course it is
none of my business but ~" is to place a period after the word "but".
Don't use excessive force in supplying such a moron with a period.
Cutting his throat is only a momentary pleasure and is bound to get
you talked about.   (RAH)

Re:Not sure if it's a bug?


Jeff,

I just checked and you are right, both IBDataSet and IBQuery are automaticly
populating Origin field.

Now is it something that was implemented during past year or so? Cause that
part of my code doesn't have Origin filed populated and it was originally
writen more that a year ago.

Thanks!

"Jeff Overcash (TeamB)" <jeffoverc...@mindspring.com> wrote in message
news:3DCBDFBA.215BA30@mindspring.com...

Quote

> Bojidar Alexandrov wrote:

> > Jeff Overcash (TeamB) wrote:
> > > You are mistaken.  This code

> > > procedure TForm1.Button1Click(Sender: TObject);
> > > begin
> > >   IBDataSet1.Close;
> > >   IBDataSet1.SelectSQL.Text := 'select * from employee';
> > >   IBDataSet1.Open;
> > >   ShowMessage(IBDataset1.FieldByName('dept_no').Origin);
> > > end;

> > > Correctly displays EMPLOYEE.DEPT_NO.  You must not be on a current
> > > version of IBX, but this was put in nearly a year ago IIRC.  If you
> > > are persisting TFIelds at design time the Origin won't change
> > > (nothing changes).

> > Your example is correct, but I have said about the case when teh fields
are
> > created design time ie persistent fields, note this in my post.

> Persisted TFields never change their values.  That is the whole point in
> persisting them at design time.  The Origin is also filled out when
persisting
> them at design time.  Once persisted though the TField values set are
never
> changed unless you explicitly do so.

> --
> Jeff Overcash (TeamB)
>       (Please do not email me directly unless  asked. Thank You)
> The correct way to punctuate a sentence that starts: "Of course it is
> none of my business but ~" is to place a period after the word "but".
> Don't use excessive force in supplying such a moron with a period.
> Cutting his throat is only a momentary pleasure and is bound to get
> you talked about.   (RAH)

Re:Not sure if it's a bug?


Quote
Hayk Petrosyan wrote:

> Jeff,

> I just checked and you are right, both IBDataSet and IBQuery are automaticly
> populating Origin field.

> Now is it something that was implemented during past year or so? Cause that
> part of my code doesn't have Origin filed populated and it was originally
> writen more that a year ago.

Take a look at the readme(s) for a history like that.  It seems like I did this
over a year ago.  It was an new feature and not an original D5 shipping
version.  I do not remember if it was done in the original D6 shipping version
or not.

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
The correct way to punctuate a sentence that starts: "Of course it is
none of my business but ~" is to place a period after the word "but".
Don't use excessive force in supplying such a moron with a period.
Cutting his throat is only a momentary pleasure and is bound to get
you talked about.   (RAH)

Other Threads