× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Sorry about PRODO. Following your suggestion, starting with: 

with temp as
(select nxkjdt, nxjpt2, sum(NXS7FQ) tran
from VNGDBDTA.DBNXCPP
where nxkjdt between 1070301 and 1070307
group by nxkjdt, nxjpt2),
temp2 as
(select dmatdt, dmekcd, sum(dmgzfq) prod
from VNGDBDTA.DBDMREP
where dmqwtx = 'SFR' and dmcdcd = ';MRCT' and
dmatdt between 1070301 and 1070307
group by dmatdt, dmekcd
)
select dmatdt, dmekcd, prod, tran
from temp2
left outer join temp on dmatdt = nxkjdt and dmekcd = nxjpt2
order by 1,2

Microsoft Query complains that PROD is not in specified tables. Removed
prod and train from the final select:

with temp as
(select nxkjdt, nxjpt2, sum(NXS7FQ) tran
from VNGDBDTA.DBNXCPP
where nxkjdt between 1070301 and 1070307
group by nxkjdt, nxjpt2),
temp2 as
(select dmatdt, dmekcd, sum(dmgzfq) prod
from VNGDBDTA.DBDMREP
where dmqwtx = 'SFR' and dmcdcd = ';MRCT' and
dmatdt between 1070301 and 1070307
group by dmatdt, dmekcd
)
select dmatdt, dmekcd
from temp2
left outer join temp on dmatdt = nxkjdt and dmekcd = nxjpt2
order by 1,2

And the Query works; but I'm not getting all the columns I want. When I
look at the SQL, all references of prod and tran are removed.

with temp as
(select nxkjdt, nxjpt2, sum(NXS7FQ) 
from VNGDBDTA.DBNXCPP
where nxkjdt between 1070301 and 1070307
group by nxkjdt, nxjpt2),
temp2 as
(select dmatdt, dmekcd, sum(dmgzfq) 
from VNGDBDTA.DBDMREP
where dmqwtx = 'SFR' and dmcdcd = ';MRCT' and
dmatdt between 1070301 and 1070307
group by dmatdt, dmekcd
)
select dmatdt, dmekcd
from temp2
left outer join temp on dmatdt = nxkjdt and dmekcd = nxjpt2
order by 1,2

Adding a qualified reference to tran:

with temp as
(select nxkjdt, nxjpt2, sum(NXS7FQ) tran
from VNGDBDTA.DBNXCPP
where nxkjdt between 1070301 and 1070307
group by nxkjdt, nxjpt2),
temp2 as
(select dmatdt, dmekcd, sum(dmgzfq) 
from VNGDBDTA.DBDMREP
where dmqwtx = 'SFR' and dmcdcd = ';MRCT' and
dmatdt between 1070301 and 1070307
group by dmatdt, dmekcd
)
select dmatdt, dmekcd, TEMP.TRAN
from temp2
left outer join temp on dmatdt = nxkjdt and dmekcd = nxjpt2
order by 1,2

Results in "SQL0205 - Column TRAN not in table TEMP in *N."

I can use this in the final select:

select *
from temp2
left outer join temp on dmatdt = nxkjdt and dmekcd = nxjpt2
order by 1,2

and I receive the data; now I can't create the derived variance in the
final select. MS Query doesn't like something about derived columns and
CTE. Using the "iSeries Access ODBC driver". As before, the original SQL
works correctly when using iNav's "Run SQL scripts".

The error messages lead me to think that the ODBC driver, not MS Query,
is validating the SQL query before execution; but I don't understand the
discrepancy between running the query via ODBC versus iNav.

Loyd Goodbar
Senior programmer/analyst
BorgWarner
TS Water Valley
662-473-5713
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Elvis Budimlic
Sent: Friday, March 09, 2007 17:11
To: 'Midrange Systems Technical Discussion'
Subject: RE: iSeries and Microsoft Query (Excel)

1) PRODO should probably be changed to PROD
2) if it still fails after that change, get rid of "AS" you're using for
your column qualifiers (i.e. change to SUM(DMGZFQ) PROD).  You shouldn't
have to do this but....

Elvis

Celebrating 10-Years of SQL Performance Excellence


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of
lgoodbar@xxxxxxxxxxxxxx
Sent: Friday, March 09, 2007 4:08 PM
To: midrange-l@xxxxxxxxxxxx
Subject: RE: iSeries and Microsoft Query (Excel)


OK. I tried both suggestions: using *SQL naming, and putting schema and
table names in upper case.

Now the error I see is: SQL0206 - Column PROD not in specified tables.

The SQL below works in iNav's Run SQL Scripts.

with TEMP as (select nxkjdt, nxjpt2, sum(NXS7FQ) as tran
from VNGDBDTA.DBNXCPP
where nxkjdt between 1070301 and 1070307
group by nxkjdt, nxjpt2),
TEMP2 as (select dmatdt, dmekcd, sum(dmgzfq) as prod
from VNGDBDTA.DBDMREP
where dmqwtx = 'SFR' and dmcdcd = ';MRCT' and
dmatdt between 1070301 and 1070307
group by dmatdt, dmekcd)
select dmatdt, dmekcd, prod, tran, prod - tran as makeup_entry 
from TEMP2
left outer join TEMP on dmatdt = nxkjdt and dmekcd = nxjpt2 where (prodo
-
tran) <> 0 order by 1,2

Thanks,
Loyd

Loyd Goodbar
Senior programmer/analyst
BorgWarner
TS Water Valley
662-473-5713

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Elvis Budimlic
Sent: Friday, March 09, 2007 16:00
To: 'Midrange Systems Technical Discussion'
Subject: RE: iSeries and Microsoft Query (Excel)

Sounds like a Microsoft problem... perhaps they assume SQL naming when
using
this interface.

That's strange since I occasionaly use Microsoft Query to test certain
things. I do go directly to it's Office folder path, rather than going
through Excel, i.e.:

"C:\Program Files\Microsoft Office\Office10\MSQRY32.EXE"

Then I click File->Execute SQL, pick a data source with *SYS naming and
all
works.

Perhaps OP can use IBM's data transfer utility instead?  
It would show as "Transfer data from iSeries..." under the Data menu
option
in Excel. That always worked for me.

Elvis

Celebrating 10-Years of SQL Performance Excellence


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Friday, March 09, 2007 2:19 PM
To: Midrange Systems Technical Discussion
Subject: Re: iSeries and Microsoft Query (Excel)


Hello,

When I enter the SQL, I get the error message "SQL Query can't be
represented graphically." I OK this non-error. However, the next error

is "Could not add the table 'vngdbdta/dbnxcpp'. One of the table
selects is vngdbdta/dbnxcpp. I verified my ODBC connection uses *SYS 
naming; the library list shouldn't matter as I'm qualifying the table 
name.

I receive the same error anytime I try to use *SYS naming.  (Even though

I have the ODBC driver configured for *SYS).   When I change my SQL 
statement to use *SQL naming (i.e., replace the slash with a dot) I have

no problem.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.