SELECT 1 FROM TABLE

jhu

Member
Hi,

I've got a strange situation here:
If I create a persisting field (in TOracleDataset) based on
SELECT FROM

I get an TIntegerField. So far so good.

If I change the SQL statement into
SELECT 1 AS FROM

and re-open the dataset, I get an error like: Type mismatch for field '', expecting: Integer actual: Float.

It seems like fixed values (needed in unions and stuff) are always seen as floats?
Any solution to this?

I really need persistent fields and fixed numbers in this case.

Thanks!
 
Any numerical select expression that is not a column of a table or view will be treated as float. Oracle does not report any scale or precision for this. Therefore there are 2 solutions:

[*] Set TOracleSession.Preferences.IntegerPrecision to 38. Now all numeric fields with a scale of 0 will be treated as integers, including the '1' expression. Note however that integer values larger than 32 bits will cause errors.

[*] Force the original field to a TFloatField through a dummy calculation. For example:

select empno+0 as empno from emp
[/list]

------------------
Marco Kalter
Allround Automations
 
Thanks for your reply.

I'm using the query in combination with a union:

select from

union
select 0 from


In this situation is a NUMBER(3). Can't I get scale/precision info from the first select?
 
The first select will return the scale and precision if is a column. Set operations like a union will lose the scale and precision though.

------------------
Marco Kalter
Allround Automations
 
Back
Top