Views and union... 
November 18th, 2008, 10:15 PM
| | | |
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. | 
November 19th, 2008, 04:15 AM
| | | | 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.
| | 
November 19th, 2008, 01:25 PM
| | | | 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:
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. | 
November 19th, 2008, 02:25 PM
| | | | 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); | 
November 19th, 2008, 02:35 PM
| | | | 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. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|