The Stored proc runs the below query and retrieves the rows and send to Front end.
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
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
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
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?
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
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