Page 1 of 1
Get the Fields Table (fields corresponding table)
Posted: Tue 21 Apr 2009 11:02
by dschuch
Hy I have a SELECT like this:
SELECT
f_a, --t_a
f_b --t_b -> alias C
FROM
t_a JOIN t_b AS c ON .....
is there is a was to get the information that field f_b is from the table with alias C ?
In the components you know (zeos ^^ ) i could do a
S:=Q.SqlParser.SqlFields.FindByName('',Q.Fields.FieldName).Table;
S:=Q.SqlParser.Aliases[Q.SqlParser.Tables.IndexOf(S)];
Posted: Tue 21 Apr 2009 11:40
by Plash
You can use the following code (add CRAccess unit to USES):
Code: Select all
var
TableInfo: TCRTableInfo;
Name, Alias: string;
begin
TableInfo := TCRFieldDesc(PgQuery1.GetFieldDesc('f_b')).TableInfo;
if TableInfo nil then begin
Name := TableInfo.TableName;
Alias := TableInfo.TableAlias;
end;
end;
Posted: Tue 21 Apr 2009 12:28
by dschuch
thnx a lot for your awnser but this doesnt work. i tried different ways the last houres but the problem seems always the same:
TCRTablesInfo.FTableNameList
as well as
TCRTablesInfo.FTableAliasList
always contains only one line with the first table of my select script (auftg).
your code is returning auftg always, too.
the script is looking like this:
perhaps you see the problem on your first look, if not, i have to try to break down my script to a smaller example.
Code: Select all
SELECT
COALESCE(ag_akbz, lang_artbez(ag_aknr, prodat_languages.customerlang(ag_lkn))) AS art_ak_bez1,
ak_znr,
ak_rust,
ak_mat,
ak_fertk,
ak_matk,
ak_awkost,
adkl.ad_fa1 AS ADKL_AD_FA1,
adkl.ad_fa2 AS ADKL_AD_FA2,
adkl.ad_str AS ADKL_AD_STR,
adkl.ad_plz AS ADKL_AD_PLZ,
adkl.ad_ort AS ADKL_AD_ORT,
a1_vers AS ADK1_A1_VERSART,
ak_zolp1b AS art_ak_zolp1b1,
lang_artmgc_id (ag_mcv, prodat_languages.customerlang(ag_lkn)) AS MGCODE_ME_BEZ1,
ag_dokunr AS AUFTG_AG_N,
atd_txt_rtf,
atd_txt1_rtf,
atd_txt AS AUFZUTXT_AZ_ZUS,
atd_txt1 AS AUFZUTXT_AZ_ZUS1,
atd_ap,
ag_txt_rtf AS auftg_ag_azutx,
(SELECT SUM(az_anz*az_abzubetrag) FROM auftgabzu WHERE az_ag_id=ag_id) AS abzusum,
lang_abzu(ag_zunr1, :LANG) AS AUFTG_AG_TXAZ1,
lang_abzu(ag_zunr2, :LANG) AS AUFTG_AG_TXAZ2,
lang_abzu(ag_zunr3, :LANG) AS AUFTG_AG_TXAZ3,
lang_abzu(ag_zunr4, :LANG) AS AUFTG_AG_TXAZ4,
lang_abzu(ag_zunr5, :LANG) AS AUFTG_AG_TXAZ5,
lang_abzu(ag_zunr6, :LANG) AS AUFTG_AG_TXAZ6,
auftg.*,
adk.*,
adk_.*,
bewa.*
FROM
auftg AS auftg JOIN art ON ak_nr=ag_aknr
JOIN adk ON ad_krz=ag_lkn
JOIN adk AS adkl ON adkl.ad_krz=ag_krzl
LEFT OUTER JOIN auftgdokutxt ON atd_dokunr=ag_dokunr
LEFT OUTER JOIN adk1 AS adk_ ON a1_krz=adk.ad_krz
LEFT OUTER JOIN bewa ON wa_einh=a1_waco
WHERE
ag_dokunr=:ag_dokunr
ORDER BY
ag_astat, ag_nr, ag_pos
Posted: Wed 22 Apr 2009 07:04
by Plash
Please make a smaller example.
Posted: Sun 26 Apr 2009 12:38
by dschuch
i have send you a demo application via email.
Posted: Thu 30 Apr 2009 08:01
by dschuch
are there any news?
Posted: Tue 05 May 2009 08:23
by Plash
We have reproduced this problem, and we are working on it. You will be notified when we fix the problem.
Posted: Tue 05 May 2009 10:33
by Plash
We have fixed this problem. The fix will be included in the next build of PgDAC.
Posted: Tue 19 May 2009 09:12
by dschuch
is there a planned release date?
perhaps you can send me a test version so i can confirm that problem.
Posted: Wed 20 May 2009 07:09
by Plash
We are planning to release the new build in a week. If you need a test version, please contact us by e-mail pgdac*devart*com, specify your Delphi version and license number.