Subject | RES: [firebird-support] Table/field Alias -> relname in SQLDA |
---|---|
Author | Antônio Cristóvão Gomes |
Post date | 2014-05-23T04:48:31Z |
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: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com]
Enviada em: quinta-feira, 22 de maio de 2014 18:44
Para: firebird-support@yahoogroups.com
Assunto: Re: [firebird-support] Table/field Alias -> relname in SQLDA
On 22-5-2014 19:15, acgomes2001@... [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 CADPROI stripped all unnecessary code from your query to reduce the size. This
> inner join CADCLI as FORNECEDOR on (FORNECEDOR.CODCLI =
> CADPRO.FORNECEDOR_PRO)
> inner join CADCLI as CLIENTE on (CLIENTE.CODCLI = CADPRO.CLIENTE_PRO)
makes it easier for us to look at it.
> Always I run sql, table and field alias for table FORNECEDOR and CLIENTEYour title mentions relname, relname is the name of the original table,
> returns CADCLI as table alias...
not a table alias.
> And is not the same table, for CADPRO will be differents the values forNo this isn't a bug. The item retrieved for XSQLVAR.relname is the
> 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?
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