The correlation names are necessary because the same table WHSEL00 is joined
several times in the select statement.
The correlation names must be used to associate the (duplicate) column names
with the right table.
I tried to reformat the Update-Statement, maybe it is clearer now what
happened.
You may copy the select statement and execute it separately.
Because we do not know your tables and their content it is difficult to
explain what really happened.
In either way key information are located somewhere in a string and must be
converted into a numeric value --> Cast(Substring(e945.aux1, 9, 8) as
Decimal(8, 0))
Also there are information in one row that point to information in another
row in the same table (--> gstctl must be connected to aux2)
exec sql                                                          
update whsel00                                                      
set aux6='ALERT NOW'                                                
where logid in (select e945.logid 
                   from whsel00  e945 left join whssd00 sd 
                        on     sdmanbl#  = cast(substring(e945.aux1,9,8) as
decimal(8,0)) 
                           and sdinvoice = e945.aux2
                                       left  join whsel00 e997  
                        on     cast(e945.gsctl as char(30))= e997.aux2 
                           and e997.snd='CUST' 
                           and e997.doc='997' )             
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!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Jack Tucky
Gesendet: Wednesday, 08. February 2012 06:15
An: 'Midrange Systems Technical Discussion'
Betreff: RE: SQL question
Like I said I don't use embedded SQL much.  
Is this code par for the course?  Why name an alias?  To save keystrokes?
Do embedded SQL dudes not normally put in comments?  At least tell me what
they are trying to do?
Jack
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of
paultherrien@xxxxxxxxxxxxxxxxxx
Sent: Tuesday, February 07, 2012 8:42 PM
To: 'Midrange Systems Technical Discussion'
Subject: RE: SQL question
E997 is the alias name he assigned for file whsel00.
"left  join whsel00 e997"  
So e997.snd is field snd in whsel00.
left  join whsel00 e997  
Paul Therrien
Andeco Software, LLC
2233 St. Charles Ave
# 704
New Orleans, LA 70130
225-229-2491
paultherrien@xxxxxxxxxxxxxxxxxx
www.andecosoftware.com
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Jack Tucky
Sent: Tuesday, February 07, 2012 6:09 PM
To: 'Midrange Systems Technical Discussion'
Subject: SQL question
I'm trying to figure out a program with no documentation and I haven't used
embedded SQL.
 
Given this code snippet from an SQLRPGLE source, can you tell me where
e997.snd is coming from?  I also can't find e945.logid.   Is there a way to
determine from the compile listing?
 
I can't find a file on the system that contains 997 in the name.
 
exec sql                                                            
update whsel00                                                      
set aux6='ALERT NOW'                                                
where logid in (                                                    
select e945.logid from whsel00  e945                                
left join whssd00 sd on sdmanbl#=cast(substring(e945.aux1,9,8) as   
decimal(8,0)) and sdinvoice =e945.aux2                              
left  join whsel00 e997  on  cast(e945.gsctl as char(30))= e997.aux2
and e997.snd='CUST' and e997.doc='997'              
 
Thanks,
Jack                
 
 
--
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: 
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.