Or Create a global Variable, and include this global variable in the view:
Create Variable YourSchema.YourVar Decimal(5, 0) Default 0;
Create View YourSchema.YourView
As (Select Fld1, Fld2, Fld3, Sum(Fld5)
From YourTable
Where RID = GblRid
Group By Fld1, Fld2, Fld3);
The Global Variable (works like a data area in the QTEMP), i.e. the value
can be set at job/connection level.
The global variable must be set before the view is used.
Exec SQL Set :YourVar = WhatEverValue;
Exec SQL Select .... into :Var1, :Var2, ... VarN
From YourView
Where ... (additional Where Conditions can be set)
Order By ...;
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: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> On Behalf Of Art
Tostaine, Jr.
Sent: Donnerstag, 30. August 2018 18:06
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: SQL View question
I have a SQL Statement in an RPG Program that uses fields that aren't in the
group by as selections. Something like this where field RID is used to
select.
When I try to create it as a view I can't access RID.
RPG SQL:
select :ls.shp, ls.sea, ls.sty, ls.clr,
ls.fab, ls.mod, ls.msz,
sum(ls.qty), sum(ls.qty)
from locsku00 ls
where ls.rid=:invrid
group by
ls.shp,
ls.sea, ls.sty, ls.clr,
ls.fab, ls.mod, ls.msz;
Create View
create view InvPhy (shp,sea,sty,clr,fab,mod,msz,qty) as (SELECT
ls.shp,ls.sea,ls.sty,ls.clr,ls.fab,ls.mod,ls.msz,SUM(ls.qty)
FROM invdta.locsku00 as ls
GROUP BY ls.shp,ls.sea,ls.sty, ls.clr,ls.fab, ls.mod, ls.msz);
Try to use the View
select * from INVPHY where rid = 81251501 and shp=50875 and sty=
'J4LW2700' order by shp,sea,sty,clr,fab,mod,msz
[SQL0206] Column or global variable RID not found. [SQL State=42703, DB
Errorcode=-206]
Can I use a view for this?
Thanks, Art
--
Art Tostaine
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
https://archive.midrange.com/midrange-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.