Consultor Eletrônico



Kbase P25342: How to create a view and give array elements a specific data type / size?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2008
Status: Verified

GOAL:

How to create a view and give array elements a specific data type / size?

FACT(s) (Environment):

Progress 9.1x

FIX:

The following sample SQL statement shows how to use the CAST function to extract an element from an array field and give it a specific data type and size so that it does not assume the default size of the array:


CREATE VIEW TestView (Field1)
AS SELECT CAST(PRO_ELEMENT(SomeArrayField,1,1) AS VARCHAR(7))
FROM PUB.SomeTable

The CAST function is used to convert the result from the PRO_ELEMENT function to a specific data type with a specific (and optional) size. The end result of the above SQL statement will be that a view named TestView will be created that contains one field (Field1) and that field will be defined with a data type of VARCHAR with a maximum length of seven (7) bytes.