|
View previous topic :: View next topic
|
| Author |
Message |
jothibso
New User
Joined: 03 Sep 2009 Posts: 18 Location: chennai
|
|
|
|
Hi,
I have a varchar(100) field say Field5 in a DB2 table which is loaded by a third party. In my SP am using this field in the inner query
| Code: |
EXEC SQL
SELECT
C.Field1 ,C.Field2
INTO
:WS-A ,:WS-B
FROM
TABLE1 A, TABLE2 B, TABLE3 C
WHERE
A.Field1 = C.Field1 AND
A.Field3 = B.Field3 AND
C.Field1 IN
(SELECT Field1 FROM TABLE3
WHERE Field4 = 1290
AND Field5 ¬= '0001')
END-EXEC
|
If Field5 is having value 0001 then Field5 len --> 4 and Field5 Text--> 0001 (remaining 96 bytes are spaces)
Scenario 1
In other cases Field5 had Field5 len --> 4 and Field5 Text --> low-values for all 100 bytes
Scenario 2
There was a new data update by the third party recently after which Field5 had the following values other than 0001 Field5 len --> 0 and Field5 Text --> Null
For Scenario 1 the above query worked whereas after data update for Scenario 2 the query did'nt work, and we had to revert back the changes.
Since we are getting the data from 3rd party we are trying to fix it from our side if possible before going back to them. We thought of doing a 1 time update however the third party does a weekly refresh, so the 1 time changes we make may not last
1. Is there any way to check for Field5 ¬= '0001' if the DB has NULL values in SP
2. Is it mandatory for the Field5 len to be 4 since we are checking 4 byte value '0001' in the query
Please help |
|
| Back to top |
|
 |
Nandhu86
New User
Joined: 03 Jun 2009 Posts: 1 Location: Chennai
|
|
|
|
Try this query for checking NULL values
| Code: |
EXEC SQL
SELECT
C.Field1 ,C.Field2
INTO
:WS-A ,:WS-B
FROM
TABLE1 A, TABLE2 B, TABLE3 C
WHERE
A.Field1 = C.Field1 AND
A.Field3 = B.Field3 AND
C.Field1 IN
(SELECT Field1 FROM TABLE3
AND (Field5 ¬= '0001' OR
FIELD5 IS NULL))
END-EXEC |
|
|
| Back to top |
|
 |
jothibso
New User
Joined: 03 Sep 2009 Posts: 18 Location: chennai
|
|
|
|
| Thanks Nandhu it worked |
|
| Back to top |
|
 |
|
|