Connecting Tech Pros Worldwide Help | Site Map

Views and union...

Karlitos
Guest
 
Posts: n/a
#1: Nov 18 '08
Here is my case :

CREATE view v1 AS
(SELECT 'E' as language,
Field1,
Field2 from libE/table1
union
SELECT 'F' as language,
Field1,
Field2 from libF/table2)

Where Field1 is the PK.
And the tables have 10 000 rows.

Then two identical files in two librairies. One per language, french
and english. We want to access these files in Cobol. We added a new
field for the language to be able to do a quick start in cobol if it
is possible. I tried to do a DBU on it and DBU doesn't see any row.
In SQL it works perfectly and it seems to be really quick. The PK
indexes have been selected.

Then my question is: is it possible to access my view with a start in
a Cobol, on the fields "language" and "Field1".

If it is not possible with this solution, how can I could do that ?

Note, I know that I could use and embeded SQL in my Cobol, but I'm
screared of the poor performance.

Thanks a lot.
Ram
Guest
 
Posts: n/a
#2: Nov 19 '08

re: Views and union...


Haven't understood your question completely but if the two tables are
having distinct (non-duplicate) records, then you may want to change
the UNION to UNION ALL to avoid an unnecessary sort.

Best regards,
ram

Karlitos wrote:
Quote:
Here is my case :
>
CREATE view v1 AS
(SELECT 'E' as language,
Field1,
Field2 from libE/table1
union
SELECT 'F' as language,
Field1,
Field2 from libF/table2)
>
Where Field1 is the PK.
And the tables have 10 000 rows.
>
Then two identical files in two librairies. One per language, french
and english. We want to access these files in Cobol. We added a new
field for the language to be able to do a quick start in cobol if it
is possible. I tried to do a DBU on it and DBU doesn't see any row.
In SQL it works perfectly and it seems to be really quick. The PK
indexes have been selected.
>
Then my question is: is it possible to access my view with a start in
a Cobol, on the fields "language" and "Field1".
>
If it is not possible with this solution, how can I could do that ?
>
Note, I know that I could use and embeded SQL in my Cobol, but I'm
screared of the poor performance.
>
Thanks a lot.
Karlitos
Guest
 
Posts: n/a
#3: Nov 19 '08

re: Views and union...


On 18 nov, 23:10, Ram <ram...@gmail.comwrote:
Quote:
Haven't understood your question completely but if the two tables are
having distinct (non-duplicate) records, then you may want to change
the UNION to UNION ALL to avoid an unnecessary sort.
>
Best regards,
ram
>
>
>
Karlitos wrote:
Quote:
Here is my case :
>
Quote:
CREATE *view v1 AS
* (SELECT 'E' as language,
* * * * * Field1,
* * * * *Field2 from libE/table1
union
SELECT 'F' as language,
* * * * * Field1,
* * * * *Field2 from libF/table2)
>
Quote:
Where Field1 is the PK.
And the tables have 10 000 rows.
>
Quote:
Then two identical files in two librairies. *One per language, french
and english. * We want to access these files in Cobol. *We added a new
field for the language to be able to do a quick start in cobol if it
is possible. *I tried to do a DBU on it and DBU doesn't see any row.
In SQL it works perfectly and it seems to be really quick. *The PK
indexes have been selected.
>
Quote:
Then my question is: is it possible to access my view with a start in
a Cobol, on the fields "language" and "Field1".
>
Quote:
If it is not possible with this solution, how can I could do that ?
>
Quote:
Note, I know that I could use and embeded SQL in my Cobol, but I'm
screared of the poor performance.
>
Quote:
Thanks a lot.- Masquer le texte des messages précédents -
>
- Afficher le texte des messages précédents -
Note i'm on a AS400 system.

My files are identical. There is a french version and a english
version in two librairies. I want to merge them with a language code
in the first column.

I added the ALL keyword and it seems that DBU is able to read now.

I want to read this view with Cobol. Is it possible ? And if yes,
can I do a direct read with the PK of the orginal files ?

THanks.
--CELKO--
Guest
 
Posts: n/a
#4: Nov 19 '08

re: Views and union...


The columns in a UNION have no names, so you need to provide them

CREATE VIEW Foobar (language_code, field1, field2 )
AS
* (SELECT 'EN' , -- use ISO Standards
* * * * *field1, field2
FROM libE/table1
UNION ALL
SELECT 'FR'
field1, field2
FROM ibF/table2);


Karlitos
Guest
 
Posts: n/a
#5: Nov 19 '08

re: Views and union...


On 19 nov, 09:19, --CELKO-- <jcelko...@earthlink.netwrote:
Quote:
The columns in a UNION have no names, so you need to provide them
>
*CREATE VIEW Foobar (language_code, field1, field2 )
*AS
** (SELECT 'EN' , -- use ISO Standards
** * * * *field1, field2
* * * FROM libE/table1
*UNION ALL
*SELECT 'FR'
* * * * * field1, field2
* FROM ibF/table2);
It doesn't help me neither, but I didn't know that there was a
standard for language code. Thanks.
Closed Thread