MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Query changes

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
shyamsaravan
Beginner


Joined: 12 May 2010
Posts: 44
Topics: 12
Location: India

PostPosted: Thu Aug 04, 2011 2:18 am    Post subject: Query changes Reply with quote

Hi
The Stored proc runs the below query and retrieves the rows and send to Front end.



Code:

SELECT DISTINCT               
       T2.LOCN       
      ,T2.PART_BSNo       
      ,T2.SRCE_TYPE     
      ,T1A.EFF_IN_DATE         
      ,T1A.CAPA_QT 
       ,CHAR(T1A.First_CREATED)   
,CHAR(T1A.LAST_UPDATE_date)
FROM  base_table        T2                       
                                                   
LEFT OUTER JOIN                                   
     Joint_table   T1A                         
                                                   
ON  T1A.LOCN      =   T2.LOCN     
AND T1A.PART_BSNo =   T2.PART_BSNO   
AND T1A.SRCE_TYPE =   T2.SRCE_TYPE 
                                                   
WHERE                                             

     T2.PART_BSNo   BETWEEN :WS-PART-BSNo-LOW   
                         AND     :WS-PART-BSNO-HIGH 
AND ((T2.LOCN  BETWEEN :WS-LOC1-CODE-LOW   
                         AND     :WS-LOC1-CODE-HIGH)
  OR  (T2.LOCN  BETWEEN :WS-LOC2-CODE-LOW   
                         AND     :WS-LOC2-CODE-HIGH)
  OR  (T2.LOCN  BETWEEN :WS-LOC3-CODE-LOW   
                         AND     :WS-LOC3-CODE-HIGH)
  OR  (T2.LOCN  BETWEEN :WS-LOC4-CODE-LOW   
                         AND     :WS-LOC4-CODE-HIGH)
  OR  (T2.LOCN  BETWEEN :WS-LOC5-CODE-LOW   
                         AND     :WS-LOC5-CODE-HIGH)
  OR  (T2.LOCN  BETWEEN :WS-LOC6-CODE-LOW   
                         AND     :WS-LOC6-CODE-HIGH))
ORDER BY T2.LOCN   
         ,T2.PART_BSNO   
         ,T2.SRCE_TYPE
         ,T1A.EFF_IN_DATE
         DESC           




Code:

Location  BaseNO     Type  StartDate      Capacity  Created Time   Updated Time
1111B      12345      S    11 DEC 2007     34       23 MAR 2005    22 NOV 2011
1111B      12345      X    13 SEP 2010     11       21 JAN 2009    12 MAY 2010
1111B      66666      Y    10 DEC 2010     41       22 MAR 2009    21 NOV 2011
2222A      11111      T    14 DEC 2009     23       11 FEB 2008    13 AUG 2010
2222A      11111      U    21 DEC 2007     34       23 MAR 2005    22 NOV 2011
2222A      77777      W    11 DEC 2010     41       22 MAR 2009    21 NOV 2011


my new requirement is changed below like this..Then we have to allow ,If customer wants to edit update the any existing column value and inserts the new row except 'Location' and 'BaseNo' and should save it to the tables.LOCN,PART_BSNO,SRCE_TYPE and EFF_IN_DATE is a combined primary key .
How to get the results.Can we need to add any new column in the table?

Code:

Location BaseNO     Type   StartDate      Capacity  Created Time   Updated Time
1111B     12345       S    11 DEC 2007     34       23 MAR 2005    22 NOV 2011
          12345       X    13 SEP 2010     11       21 JAN 2009    12 MAY 2010
          66666       Y    10 DEC 2010     41       22 MAR 2009    21 NOV 2011
2222A     11111       T    14 DEC 2009     23       11 FEB 2008    13 AUG 2010
          11111       U    21 DEC 2007     34       23 MAR 2005    22 NOV 2011
          77777       W    11 DEC 2010     41       22 MAR 2009    21 NOV 2011


Thanks
shyam
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Thu Aug 04, 2011 9:21 pm    Post subject: Reply with quote

If the new rows are to be useful, do they not need the Locaton value in each row?

If i understand what you have posted, you are creating "data" not a report Confused

Possibly i misunderstand something.
_________________
All the best,

di
Back to top
View user's profile Send private message
shyamsaravan
Beginner


Joined: 12 May 2010
Posts: 44
Topics: 12
Location: India

PostPosted: Fri Aug 12, 2011 5:35 am    Post subject: Reply with quote

Hi ;

Requirement is changed little bit.Below will be the new screen in future.We are going to add another column 'YEAR' after the 'BASENO'.The year should always display the Current year + 2 year for every 'Location' column.Each row we can edit and update the column values after the 'YEAR' column values.How to write the query to fetch the values.

Code:

Location BaseNO     Year      Type     StartDate       
1111B     12345    2011        S     11 DEC 2007
       

          12345    2012        X     13 SEP 2010
       

          66666    2013        Y     10 DEC 2010

2222A     11111    2011        T     14 DEC 2009
          11111    2011        U     21 DEC 2007
 
       
          77777    2012        W     11 DEC 2010   
          77777    2012        Z     23 JAN 2011
       
          77777    2013        W     11 DEC 2010
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group