|
P.S. May I add (quite off topic) that your business signature sometimesthey
should be banned? Depending on how near is one's time for lunch/dinner
can be quite tormenting :-)
Michael,record
I don't really look at SQL as a way of encapsulating code, but as a way
of encapsulating business rules. It does not matter if you need one
or one million, one field or many, RPG, QRY, QM, ODBC, etc. A welldescribed
SQL structure works for everything, at the most basic of levels.As I
That said, it depends, as I wrote before, on your business needs
(performance, kind of programs, etc), so the mileage can (and do) vary.
see it, in the programming world, as in real life, there are not unique,
work for all, solutions.
Best Regards,
Luis Rodriguez
and
On Fri, Jun 11, 2010 at 8:38 AM, <Michael_Schutte@xxxxxxxxxxxx> wrote:
Who says you cant encapsulate this code? Put it in a service program
beststill get what you want.
--
Michael Schutte
Admin Professional
Announcing Bob Evans Bob-B-QÂ Road Trip! For a limited time, America's
businessBob-B-QÂ tastes are all at Bob Evans! For more information, visit
www.bobevans.com/menu/seasonal.aspx
midrange-l-bounces@xxxxxxxxxxxx wrote on 06/11/2010 04:14:27 AM:
Michael,other
Sometimes it just might be easier to write the program with I/O.
Yes, of course. As always, it depends on your business needs. On the
hand, as I see it, one of the main advantages of doing this kind ofsolution
(Birgitta's SQL solution) is that you can define a particular
severalrule
just once, encapsulate in a SQL view and have it accessible for
thedevelopers and/or programs, queries, etc., without having to reinvent
appealwheel every time (by nature, I am lazy, so this kind of solutions
forto
me :-) ).
Also, there is what I suspect is the main interest in this kind of
solutions: Just to see if and how can be done. In other words, just
wrote:the
heck of it...
Best Regards,
Luis Rodriguez
IBM Certified Systems Expert â eServer i5 iSeries
On Fri, Jun 11, 2010 at 7:49 AM, <Michael_Schutte@xxxxxxxxxxxx>
America's
Sometimes it just might be easier to write the program with I/O.
DoW not %EoF(PRMAST);
Read PRMAST;
If %EoF(PRMAST);
Leave;
EndIf;
Chain (empno) DEDBAL;
If not %Found();
// Clear fields;
employee_contributions = 0;
employer_contributions = 0;
EndIf;
Wages = 0;
SetLL (empno) INCBAL;
Dow not %EoF(INCBAL);
Read INCBAL;
If %EoF();
Leave;
EndIf;
// sum wages
Wages += income_amount;
EndDo;
// Print employee data
EndDo;
--
Michael Schutte
Admin Professional
Announcing Bob Evans Bob-B-QÂ Road Trip! For a limited time,
anybest
ToBob-B-QÂ tastes are all at Bob Evans! For more information, visit
www.bobevans.com/menu/seasonal.aspx
"Dennis Lovelady"
<iseries@lovelady
.com>
ccSent by: "'Midrange Systems Technical
midrange-l-bounce Discussion'"
s@xxxxxxxxxxxx <midrange-l@xxxxxxxxxxxx>
Subject
06/10/2010 06:30
PM RE: SQL Join - all rows from
totable for employee
Please respond to
Midrange Systems
Technical
Discussion
<midrange-l@midra
nge.com>
Yeah, I was pretty loose about the specifics because I don't want
don't.give
the impression that I want someone else to write this for me. I
stuff.But
here we go:
DEDBAL contains quarterly deduction amounts (employer and employee
contribution), the year, the quarter, employee number and other
year,
INCBAL contains quarterly income amounts, Federal wage base, the
otherthe
amounts),quarter, employee and other stuff.
I need employee name, year, quarter, max(wage base), sum(income
sum(employee contribution), sum(employer contribution) and some
dotogetherstuff.
So from these three tables, I need multiple columns of each, put
onto a single row by employee.
UNION might work, but I don't think UNION DISTINCT (by itself) will
thewhat
I want. I could do a left outer and an exception join, but then
(butsumming
and other details would get complex and would need to be mostly
anot
somecompletely) duplicated. Messy.
I liked the look of FULL JOIN, but apparently that's only available
after V5R3, which is where we are.
Likely I'll just write a program, but I wondered if there might be
onemore
standard solution.
Sorry I wasn't completely upfront before. I just don't want to be
ofof
those "here's my task - do it for me" people.
Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"A cynic is a man who knows the price of everything and the value
LEFTEXISTS.nothing."
-- Oscar Wilde
Do you need info from DEDBAL and INCBAL? If not, you could use
SELECT * <-- desired fields from PRMAST go here
FROM PRMAST
WHERE EXISTS (SELECT 1 FROM DEDBAL WHERE DEDEMP=PREMP)
OR EXISTS (SELECT 1 FROM INCBAL WHERE INCEMP=PREMP)
If you need to pull data from DEDBAL and INCBAL, you could use a
hereDEDEMPOUTER
join
and then exclude those cases where an employee has no records in
and
INCEMP.
Try this:
SELECT * <-- desired fields from PRMAST, DEDBAL, and INCBAL go
INCBAL,FROM PRMAST
LEFT OUTER JOIN DEDBAL ON DEDEMP=PREMP
LEFT OUTER JOIN INCBAL ON INCEMP=PREMP
WHERE DEDEMP IS NOT NULL OR INCEMP IS NOT NULL
In this case, if an employee has records in DEDBAL but not in
PREMP).Loveladyany
fields in INCBAL would be null and vice versa.
Have fun!
Richard Casey
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Dennis
Sent: Thursday, June 10, 2010 3:38 PM
To: 'Midrange Systems Technical Discussion'
Subject: SQL Join - all rows from any table for employee
We have three tables: DEDBAL, INCBAL, and PRMAST.
Each of these contains an employee number (DEDEMP, INCEMP,
DEDBALWe
want
to produce output where an employee is represented in either
PRMASTand
INCBAL or both. (For the sake of argument, we can assume that
andis
present for each employee).
I've tried various types of joins (LEFT OUTER, FULL, et cetera)
means ofhave
pored through the archives and GOOGLE and come up empty on a
manyissuedoing
this exactly right. (I'm convinced this is a common issue; so my
is
probably my choice of search words - usually resulting in too
writehits).
Would some kind soul mind directing me to guidelines on how to
mailingmailingthe
JOIN for this challenge?
Thanks!
Dennis E. Lovelady
AIM/Skype: delovelady MSN: fastcounter@xxxxxxxxxxxx
<http://www.linkedin.com/in/dennislovelady>
www.linkedin.com/in/dennislovelady --
I am at one with my duality.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailinglist
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailinglist
To post a message email: MIDRANGE-L@xxxxxxxxxxxx--
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
listlist
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
listTo post a message email: MIDRANGE-L@xxxxxxxxxxxx--
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.