then why not include "Alias Table" in "XSQLVAR"?
this function should be used to retrieve the table alias?
function isc_dsql_sql_info(user_status: PISCStatus; stmt_handle: PIscStmtHandle;
item_length: Smallint; items: PISCSChar; buffer_length: Smallint; buffer:
PISCSChar):
ISCStatus;
thanks
________________________________________
Antônio Cristóvão Gomes
AML-Software
Telefone: 32-3531-5071 Cel: 32-9104-2963
Ubá - MG
De: [email protected] [mailto:[email protected]]
Enviada em: quinta-feira, 22 de maio de 2014 18:44
Para: [email protected]
Assunto: Re: [firebird-support] Table/field Alias -> relname in SQLDA
On 22-5-2014 19:15, [email protected] <mailto:[email protected]>
[firebird-support] wrote:
> I have the SQL:
>
> select
> CADPRO.CLIENTE_PRO,
> CADPRO.FORNECEDOR_PRO,
...
> FORNECEDOR.NOME_CLI NOME_FORNECEDOR,
> CLIENTE.NOME_CLI NOME_CLIENTE,
..
> from CADPRO
> inner join CADCLI as FORNECEDOR on (FORNECEDOR.CODCLI =
> CADPRO.FORNECEDOR_PRO)
> inner join CADCLI as CLIENTE on (CLIENTE.CODCLI = CADPRO.CLIENTE_PRO)
I stripped all unnecessary code from your query to reduce the size. This
makes it easier for us to look at it.
> Always I run sql, table and field alias for table FORNECEDOR and CLIENTE
> returns CADCLI as table alias...
Your title mentions relname, relname is the name of the original table,
not a table alias.
> And is not the same table, for CADPRO will be differents the values for
> fields "CADPRO.CLIENTE_PRO" and "CADPRO.FORNECEDOR_PRO"
>
> I run the sql, and field origin always returns CADCLI.NOME_CLI instead
> of FORNECEDOR.NOME_FORNECEDOR
>
> and "CADCLI.NOME_CLI" instead of CLIENTE.NOME_CLIENTE.
>
> Its a bug?
No this isn't a bug. The item retrieved for XSQLVAR.relname is the
information item isc_info_sql_relation which is always the original
table of the field. So relname will contain the table name, not its
alias within the query. The alias needs to be retrieved explicitly by a
client (or tool) with a call to isc_dsql_sql_info with the
isc_info_sql_relation_alias information item.
Something similar applies to XSQLVAR.sqlname which will contain the
original column name (isc_info_sql_field), not its alias
(isc_info_sql_alias, which is in aliasname). Although this field is
included in the XSQLVAR.
Mark
--
Mark Rotteveel