TdaSQLBuilder and Expression
Hi All,
How to use TdaSQLBuilder to create a expression calcfield with field
alias in the statement result?
i.e.:
SELECT tab.cod, 2 ide FROM tab
When I tried to use calcfield, the Sql statement generated by
TdaSQLBuilder was:
SELECT tab.cod, 2 2 FROM tab
TIA,
Laercio
How to use TdaSQLBuilder to create a expression calcfield with field
alias in the statement result?
i.e.:
SELECT tab.cod, 2 ide FROM tab
When I tried to use calcfield, the Sql statement generated by
TdaSQLBuilder was:
SELECT tab.cod, 2 2 FROM tab
TIA,
Laercio
This discussion has been closed.
Comments
Please post the TdaSQLBuilder code you are using and I will test it on my
machine.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
aSql := TdaSQLBuilder.Create( ppReport1 );
aSql.Clear;
aSql.SelectFields.Add( 'TAB', 'COD' );
aSql.CalcFields.AddExpression( '2 AS IDE' );
// Result: SELECT TAB.COD, 2 2 FROM TAB
//
// I expected: SELECT TAB.COD, 2 IDE FROM TAB
By the way: I'm using D7, RB 9.02, Oracle 9i
TIA,
Laércio
The expression cannot contain a field alias. The best way to determine what
is allowed in the TdaSQLBuilder is to try it first in the Query Designer.
It is possible to change the SQL Field alias of a calcuated field using the
code below, however ReportBuilder does not use this value at any time during
design or generation. You may want to change the Field Alias instead.
aSql := TdaSQLBuilder.Create( ppReport1 );
aSql.Clear;
aSql.SelectFields.Add( 'TAB', 'COD' );
lCalcField := aSql.CalcFields.AddExpression( '2' );
//Change SQL Field Alias (not needed)
lCalcField.SQLFieldName := 'IDE';
//Change Field Alias (used by RB)
lCalcField.FieldAlias := 'IDE';
aSQL.ApplyUpdates;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com