Subject | Re: Expressions |
---|---|
Author | Adam |
Post date | 2005-07-19T23:35:25Z |
--- In firebird-support@yahoogroups.com, "nk_karasu" <nkkarasu@g...>
wrote:
some form of number (integer / float / numeric / etc) because you are
calling it FieldsTotal.
That procedure will work if both AField and AnOtherField are exactly
the same type, otherwise it will not work. Some development tools are
clever enough to automatically cast the fields as the right type, but
AFAIK Firebird will assume the field type will be the same as AField,
which means is AnOtherField is not of that type you will have
problems.
In that case, you need to pick the lowest denominator, so if AField
is an integer and AnOtherField is a float, then you will need to cast
AField as a float to do the math.
eg:
SELECT (CAST(AField as Float) + AnOtherField) AS FieldTotals ....
You could certainly do it inside a SP as well, but you would have the
same problems trying to add a float to an integer and store it in an
integer field.
Hope that helps
Adam
wrote:
> Hi.Stored
>
> The query below dosn't work.
>
> "SELECT (AField + AnOtherField) AS FieldsTotal FROM FieldsTable"
>
> Is there a way to run queries includes expressions in ib/fb(Like
> procedures etc.).Looking at your query, I am guessing AField and AnOtherField are both
>
> Thanks for help...
some form of number (integer / float / numeric / etc) because you are
calling it FieldsTotal.
That procedure will work if both AField and AnOtherField are exactly
the same type, otherwise it will not work. Some development tools are
clever enough to automatically cast the fields as the right type, but
AFAIK Firebird will assume the field type will be the same as AField,
which means is AnOtherField is not of that type you will have
problems.
In that case, you need to pick the lowest denominator, so if AField
is an integer and AnOtherField is a float, then you will need to cast
AField as a float to do the math.
eg:
SELECT (CAST(AField as Float) + AnOtherField) AS FieldTotals ....
You could certainly do it inside a SP as well, but you would have the
same problems trying to add a float to an integer and store it in an
integer field.
Hope that helps
Adam