View with correlated subquery

Maxim Ness

Active Member
Hello experts,

I am straggling to create a view with subselect in it. When executed the query itself runs fine, but when I attempt to create a view I get an error. Version of iSeries is V5R1. Any suggestions are welcome. Thank you! Here’s the example:
CREATE VIEW V_VZA_DIM_ASSET (
ORGANIZATION_ID,
ORGANIZATION_NAME
)
AS
SELECT
FACO ORGANIZATION_ID,
(SELECT c.CCNAME FROM F0010 c WHERE c.CCCO = a.FACO) as ORGANIZATION_NAME
FROM
F1201 a, F1217 e where a.FANUMB = e.WRNUMB
 
Maxim Ness,
I've never needed to create a view. However, given that your query runs fine, I'd expect your joblog to include at least one error message. What error do you get?

You may not have the authority to create a view. You may not have the authority to use the library where your view will reside. Your statement may not match your query & may be invalid. Have you been able to successfully create views without a subquery?
Debi
 
Maxim Ness,

I would qualify view name (CREATE VIEW libname.V_VZA_DIM_ASSET). If that doesn’t help then I would try:
CREATE VIEW libname.V_VZA_DIM_ASSET (
ORGANIZATION_ID,
ORGANIZATION_NAME
)
AS
SELECT
FACO, CCNAME
FROM
F1201 JOIN F1217 ON FANUMB = WRNUMB
LEFT JOIN F0010 on FACO = CCCO

Hope this helps,
Boyan
 
Back
Top