Subject | RE: [IBO] Search mode and table aliases |
---|---|
Author | Aleš Kahánek |
Post date | 2003-04-10T09:37:53Z |
Jason,
I have already traced and problem seems to be here, in the procedure
ExtractWhereClause
....
fld := '';
if ( SQLName <> '' ) then
begin
if ( SQLType = SQL_VARYING ) or
( SQLType = SQL_VARYING_ ) or
( SQLType = SQL_TEXT ) or
( SQLType = SQL_TEXT_ ) then
begin
fld := NoCaseFieldName;
if fld = '' then
fld := FullFieldName
else
SearchBuffer := AnsiUpperCase( SearchBuffer );
end
else
fld := BestFieldName
end;
if fld = '' then
fld := GetCharValues( Statement.SysFieldNames[FieldNo] );
The procedures NoCaseFieldName, FullFieldName or BestFieldName do not know
nothing about the fact, than table is being used twice in the query with
different aliases and I guess, that IB API does not provide such type of
information. In the XSQLDA is defined variable char aliasname[32] and this
is the field alias, but I did not find anything about the table alias.
So I suppose that the following could help.
I am used to define in the TIB_Query.ColumnAttributes this entry (I use this
due to some specific processing, where I need to know the table alias):
MYCOLUMNNAME=ALIAS_TABLE=MYTABLE_ALIAS
We could somewhere check, if this alias is defined in the ColumnAttributes
if IsColAttributeSet[BestFieldName, 'ALIAS_TABLE'] then
fld := ColAttributeParams[BestFieldName, 'ALIAS_TABLE'] + '.' +
BestFieldName;
Or maybe introducing new property called RelAliasName could be a way.
This is only an idea, I would like to know your opinion and then if you
agree, I can do further changes and tests and send you the resulted code.
Ales
I have already traced and problem seems to be here, in the procedure
ExtractWhereClause
....
fld := '';
if ( SQLName <> '' ) then
begin
if ( SQLType = SQL_VARYING ) or
( SQLType = SQL_VARYING_ ) or
( SQLType = SQL_TEXT ) or
( SQLType = SQL_TEXT_ ) then
begin
fld := NoCaseFieldName;
if fld = '' then
fld := FullFieldName
else
SearchBuffer := AnsiUpperCase( SearchBuffer );
end
else
fld := BestFieldName
end;
if fld = '' then
fld := GetCharValues( Statement.SysFieldNames[FieldNo] );
The procedures NoCaseFieldName, FullFieldName or BestFieldName do not know
nothing about the fact, than table is being used twice in the query with
different aliases and I guess, that IB API does not provide such type of
information. In the XSQLDA is defined variable char aliasname[32] and this
is the field alias, but I did not find anything about the table alias.
So I suppose that the following could help.
I am used to define in the TIB_Query.ColumnAttributes this entry (I use this
due to some specific processing, where I need to know the table alias):
MYCOLUMNNAME=ALIAS_TABLE=MYTABLE_ALIAS
We could somewhere check, if this alias is defined in the ColumnAttributes
if IsColAttributeSet[BestFieldName, 'ALIAS_TABLE'] then
fld := ColAttributeParams[BestFieldName, 'ALIAS_TABLE'] + '.' +
BestFieldName;
Or maybe introducing new property called RelAliasName could be a way.
This is only an idea, I would like to know your opinion and then if you
agree, I can do further changes and tests and send you the resulted code.
Ales
> -----Original Message-----
> From: Jason Wharton [mailto:jwharton@...]
> Sent: Thursday, April 10, 2003 12:41 AM
> To: IBObjects@yahoogroups.com
> Subject: Re: [IBO] Search mode and table aliases
>
>
> I wonder if you would not mind tracing into the code in
> IB_Parse.pas and see
> if you can suggest a fix for this.
>
> Thanks,
> Jason Wharton
> CPS - Computer Programming Solutions
> Mesa Arizona
> http://www.ibobjects.com
>
> -- We may not have it all together --
> -- But together we have it all --
>