Field Alias - Origin field
Field Alias - Origin field
When I run sql:
select CADPRO.CODIGO_PRO,
CADPRO.DESCRICAO_PRO,
F.NOME_CLI "Razão Social do Fornecedor",
C.NOME_CLI "Razão Social do Cliente"
from CADPRO
inner join CADCLI F on (F.CODCLI = CADPRO.FORNECEDOR_PRO)
inner join CADCLI C on (C.CODCLI = CADPRO.CLIENTE_PRO)
The field origin doesnt work...
see the TFieldDefs
object UniQuery1CODIGO_PRO: TIntegerField
FieldName = 'CODIGO_PRO'
Origin = 'CADPRO.CODIGO_PRO'
Required = True
end
object UniQuery1DESCRICAO_PRO: TStringField
FieldName = 'DESCRICAO_PRO'
Origin = 'CADPRO.DESCRICAO_PRO'
Size = 50
end
object UniQuery1RazãoSocialdoFornecedor: TStringField
FieldName = 'Raz'#227'o Social do Fornecedor'
Origin = 'CADCLI.NOME_CLI' <<<<<<<<<<<<<<<<<<Wrong here
ReadOnly = True
Size = 50
end
object UniQuery1RazãoSocialdoCliente: TStringField
FieldName = 'Raz'#227'o Social do Cliente'
Origin = 'CADCLI.NOME_CLI' <<<<<<<<<<<<<<<<<<Wrong here
ReadOnly = True
Size = 50
end
why its happens?
PS: Firebird - Unidac
select CADPRO.CODIGO_PRO,
CADPRO.DESCRICAO_PRO,
F.NOME_CLI "Razão Social do Fornecedor",
C.NOME_CLI "Razão Social do Cliente"
from CADPRO
inner join CADCLI F on (F.CODCLI = CADPRO.FORNECEDOR_PRO)
inner join CADCLI C on (C.CODCLI = CADPRO.CLIENTE_PRO)
The field origin doesnt work...
see the TFieldDefs
object UniQuery1CODIGO_PRO: TIntegerField
FieldName = 'CODIGO_PRO'
Origin = 'CADPRO.CODIGO_PRO'
Required = True
end
object UniQuery1DESCRICAO_PRO: TStringField
FieldName = 'DESCRICAO_PRO'
Origin = 'CADPRO.DESCRICAO_PRO'
Size = 50
end
object UniQuery1RazãoSocialdoFornecedor: TStringField
FieldName = 'Raz'#227'o Social do Fornecedor'
Origin = 'CADCLI.NOME_CLI' <<<<<<<<<<<<<<<<<<Wrong here
ReadOnly = True
Size = 50
end
object UniQuery1RazãoSocialdoCliente: TStringField
FieldName = 'Raz'#227'o Social do Cliente'
Origin = 'CADCLI.NOME_CLI' <<<<<<<<<<<<<<<<<<Wrong here
ReadOnly = True
Size = 50
end
why its happens?
PS: Firebird - Unidac
Re: Field Alias - Origin field
The Origin property in your sample contains correct information - it specifies the field name in the database table.
You can find more details about the Origin property in the Embarcadero documentation:
http://docwiki.embarcadero.com/Librarie ... eld.Origin
You can find more details about the Origin property in the Embarcadero documentation:
http://docwiki.embarcadero.com/Librarie ... eld.Origin
Re: Field Alias - Origin field
then when I do the filter in sql:
sFieldName: = 'Razão Social do Cliente';
scampo: = TUniQuery (DSC) FindField (sFieldName).Origin; => result: CADCLI.NOME_CLI
sWhere: = '((UPPER (' scampo + + ') LIKE' + QuotedStr (iif (CheckParte.Checked, '%','') + Trim (EditNome.Text) + '%') + ')';
For scampo have the table name of "CADCLI.NOME_CLI" and not "C.NOME_CLI" as a result will generate a wrong filter in sql.
Note:
in help in the "table name" (CUSTOMER) does not have alias name...
this case, the sql would not wrong.
sFieldName: = 'Razão Social do Cliente';
scampo: = TUniQuery (DSC) FindField (sFieldName).Origin; => result: CADCLI.NOME_CLI
sWhere: = '((UPPER (' scampo + + ') LIKE' + QuotedStr (iif (CheckParte.Checked, '%','') + Trim (EditNome.Text) + '%') + ')';
For scampo have the table name of "CADCLI.NOME_CLI" and not "C.NOME_CLI" as a result will generate a wrong filter in sql.
Note:
in help in the "table name" (CUSTOMER) does not have alias name...
this case, the sql would not wrong.
Re: Field Alias - Origin field
To retrieve a table alias for a certain dataset field, use the TableInfo property of the TCRFieldDesc class:
The TCRFieldDesc class is defined in the CRAccess module, the TDBAccessUtils class is defined in the DBAccess module.
The problem is that Firebird doesn't return information about aliases, and when a table is used in a query with several aliases, then the TableAlias property will contain the name of the first alias assigned to this table.
Code: Select all
TCRFieldDesc(TDBAccessUtils.GetIRecordSet(UniQuery1).Fields[i]).TableInfo.TableAliasThe problem is that Firebird doesn't return information about aliases, and when a table is used in a query with several aliases, then the TableAlias property will contain the name of the first alias assigned to this table.
Re: Field Alias - Origin field
hello:
TCRFieldDesc(TDBAccessUtils.GetIRecordSet(UniQuery1).Fields).TableInfo.TableAlias
I tried using this way, but, TableAlias always is empty.
The problem could be in: Unit IBCClassesUni
on procedure:
procedure FillTablesAliases;
and
procedure DescribeDefineFieldDesc(Field: TIBCFieldDesc; SQLVAR: TSQLVARAccessor; FieldNo: integer);
Note that, always set TableAlias to a empty string.
----
"SQLVAR" returns wrong because when you repeat a table in sql, does not add "TableInfo"
the source code:
if FldTableName <> '' then begin
TableInfo := FTablesInfo.FindByName(FldTableName);
if TableInfo = nil then // here, "cadcli" adds only once
begin
TableInfo := FTablesInfo.Add;
TableInfo.TableName := FldTableName;
TableInfo.TableAlias := '';
end;
Field.TableInfo := TableInfo;
end
else
Field.TableInfo := nil;
----------------------------------
Platform: FB 2.5.2
Delphi XE5.
TCRFieldDesc(TDBAccessUtils.GetIRecordSet(UniQuery1).Fields).TableInfo.TableAlias
I tried using this way, but, TableAlias always is empty.
The problem could be in: Unit IBCClassesUni
on procedure:
procedure FillTablesAliases;
and
procedure DescribeDefineFieldDesc(Field: TIBCFieldDesc; SQLVAR: TSQLVARAccessor; FieldNo: integer);
Note that, always set TableAlias to a empty string.
----
"SQLVAR" returns wrong because when you repeat a table in sql, does not add "TableInfo"
the source code:
if FldTableName <> '' then begin
TableInfo := FTablesInfo.FindByName(FldTableName);
if TableInfo = nil then // here, "cadcli" adds only once
begin
TableInfo := FTablesInfo.Add;
TableInfo.TableName := FldTableName;
TableInfo.TableAlias := '';
end;
Field.TableInfo := TableInfo;
end
else
Field.TableInfo := nil;
----------------------------------
Platform: FB 2.5.2
Delphi XE5.
Re: Field Alias - Origin field
PavloP
Its a possible solution ?
https://golden-temp.googlecode.com/svn/ ... ataSet.pas
find by function TFIBCustomDataSet.GetFieldOrigin(Fld:TField):string;
Its a possible solution ?
https://golden-temp.googlecode.com/svn/ ... ataSet.pas
find by function TFIBCustomDataSet.GetFieldOrigin(Fld:TField):string;
Re: Field Alias - Origin field
We are investigating the possibility of implementing such functionality in one of the next UniDAC builds.
As soon as we implement the functionality, we can send you a night build including the fix. We will inform you when we have any results.
As soon as we implement the functionality, we can send you a night build including the fix. We will inform you when we have any results.
Re: Field Alias - Origin field
We have implemented the functionality. The fix will be included in the next UniDAC build.
For now, we can send you a night build including the fix. Please send an email to eugeniyz*devart*com, in which specify your license number (if you are a registered user).
For now, we can send you a night build including the fix. Please send an email to eugeniyz*devart*com, in which specify your license number (if you are a registered user).