Larry,

You can explicitly tell R:Base what datatype to give a calculated column in a 
view, 
with this little trick.

If the SQL for your original view looks like this ...

CREATE VIEW PhonesView +
(AreaCode, PhoneNumber, WholeThing) +
AS SELECT AreaCode, PhoneNumber, (AreaCode + '-' + PhoneNumber) +
FROM PhonesTable

... and you would like the view column WholeThing treated as TEXT (18), then 
define 
the view this way:

CREATE VIEW PhonesView +
(AreaCode, PhoneNumber, WholeThing) +
AS SELECT AreaCode, PhoneNumber, Sys_Table_Name +
FROM PhoneTable t1, Sys_Tables t2 +
WHERE COUNT = 0 +
UNION ALL SELECT +
AreaCode, PhoneNumber, (AreaCode + '-' + PhoneNumber) +
FROM PhonesTable

This will work because R:Base will use the column definitions from the first 
SELECT 
in a UNION ALL SELECT construction to determine the data types that must match 
through all the SELECTS in the chain of queries. There are no "expressions" in 
that 
first query, just real columns from real tables.  When the view is assembled 
and goes 
on to the second query, in the case of your computed expression, R:Base will be 
able to "cast" your expression into the TEXT(18) datatype it is already 
expecting 
without a problem.

The first query has a WHERE clause that returns no rows, so on retrieval, 
R:Base 
just checks, gets no rows form the first query, then goes on to your real query.

Bill

On 3 Jan 2005 at 11:47, Lawrence Lustig wrote:

> I have a view that includes several fields including a calculated
> phone number field with the expression (AreaCode + '-' + PhoneNumber).
>  
> Does anyone have a good way to display these values in a form? --
> Larry
> 

Reply via email to