In the meantime, as I mentioned to Birgitta I still won't create a VIEW if it's only used in one program, and in that case using externally described fields to build the data structure is perfectly fine.
We can discuss about this statement, but finally everybody has to decide by himself what may be the best for him.
Those statement "I only use it in a single program" may be true today, and may be true tomorrow, but in 6 month someone decides that the result has to be downloaded with Excel or must be displayed in a web application or the java programmer has to consume the same data.
What unfortunately happens mostly, the complete SQL statement is copied (it's only only another program). ... and 1 year later the data is needed in another environment (only another program!)
An now imagine, you have to modify something, you have to find all occurrences of your SQL statement and modify it in all environments.
If you had a view, you'd simply have to modify the view.
I never state "I only need it in a single program", but "I expect it may be used in multiple programs". In this way I decide to create and use views.
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them and keeping them!"
„Train people well enough so they can leave, treat them well enough so they don't want to.“ (Richard Branson)
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joe Pluta
Sent: Samstag, 2. September 2017 03:57
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: SQL and defining data structures
"sounds like you are not very familiar with views"
Heh. Yes, I was thinking about reasons to create a prepared statement, and conflated that with reasons for not using a VIEW. Of course the ORDER BY doesn't impact the VIEW. My mistake.
But thank you for pointing that out so politely. That's what makes this list so much fun! ;)
In the meantime, as I mentioned to Birgitta I still won't create a VIEW if it's only used in one program, and in that case using externally described fields to build the data structure is perfectly fine.
<Joe>
For example, if I need to select the library at run time, or the ORDER
BY criteria can be changed at run time.
</Joe>
sounds like you are not very familar with views. DB2 on AS/400 (and
all following systems) doesn't allow an order by in the top select and
even drops tricky order by clauses (as allowed in other flavours of DB2).
In this special case I would indeed recommend not to use views in
Germany we are saying: "Schuster bleib bei Deinen Leisten"
D*B
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.