×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Hi Marco,

We also had some problems with the SQL precompiler and qualified
datastructures in the releases V5R1 and V5R2.
We copied the qualified datastructure into a separate member and embedded
this member as copy file with /INCLUDE.
May be you can use this as quick and dirty solution.

Mit freundlichen Gruessen / Best regards

Birgitta

"Shoot for the moon, even if you miss, you'll land among the stars."
(Les Brown)

-----Ursprungliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]Im Auftrag von Marco Facchinetti
Gesendet: Samstag, 5. August 2006 09:20
An: RPG programming on the AS400 / iSeries
Betreff: SQL0312 and qualified DS


The following code will get an SQL0312 even if the code itself is ok:

...
dwqty             s                   like(qty     )
dwcustcode        S                   ike(custcode)
d clid            ds                  qualified inz
d  custcode                           like(custcode) dim(999)
d  qty                                like(qty) inz(0) dim(999)
d  n                            10i 0 inz(0)
...
w_select = 'SELECT GMCUSTCODE, SUM(GMQTY * GMSIGN) ';
...
MARCOC/exec sql
MARCOC+    FETCH CURS1 INTO :WCUSTCODE,:WQTY
MARCOC/end-exec

Qty and custcode are defined in an external ds and used as basing fields for
many other variables.

To avoid the problem I have 2 possible solutions, the first is horrible:
...
d*wqty             s                   like(qty     )
d*wcustcode        S                   ike(custcode)
dwqty             s             16  4
dwcustcode        s              6
...

the second is adding an x (changing de facto the name):

d clid            ds                  qualified inz
d  custcodex                          like(custcode) dim(999)
d  qtyx                               like(qty) inz(0) dim(999)
d  n                            10i 0 inz(0)

I'm not sure if this is an error or the precompiler is just behaving as
documented since the manual states:

"The names of host variables must be unique within the program, even if the
host variables are in different procedures. However, if a data structure has
the QUALIFIED keyword, then the subfields of that data structure can have
the same name as a subfield in a different data structure or as a
stand-alone variable. The subfield of a data structure with the QUALIFIED
keyword must be referenced using the data structure name to qualify the
subfield name."

I honestly don't know if is the case or not to open a PMR, any opinion?

Thanks
Marco

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
This is the RPG programming on the AS400 / 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.




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-2026 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.