Hi i need to write a query on the following requirement.
SELECT COMM_TEXT
INTO :WS_MIKM_COMM_TEXT
FROM MPIPROD.MIKMV01
WHERE ACCOUNT_NO = :WFD_ACCOUNT_NO
AND (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT
AND SUBSTR(COMM_TEXT,47,14) = :WS_DENY_DESC)
OR (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT)
The above query is to be modified. The requirement is if
both the fields are equal then that has to be given
priority. In the above query if it satisfies any one it
comes out without checking if both being equal is possible.
SELECT COMM_TEXT
INTO :WS_MIKM_COMM_TEXT
FROM MPIPROD.MIKMV01
WHERE (CASE WHEN (SUBSTR(COMM_TEXT,1,39 = :WS_COMMENT_TEXT)
AND SUBSTR(COMM_TEXT,47,14) = :WS_DENY_DESC)) THEN 1
ELSE
(SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT) THEN 2
END) IN (1,2)
AND ACCOUNT_NO = :WFD_ACCOUNT_NO
Tell me if i am wrong??
ACCOUNT_NO = :WFD_ACCOUNT_NO
AND CASE
OR (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT)
Is This Answer Correct ? | 0 Yes | 0 No |
How many buffer pools are available in db2?
what is load and unload in db2
What is referential integrity?
List out the three types of page locks that can be held.
List some fields from sqlca?
What is the purpose of coding FETCH in a SQL SELECT query? Explain with an example in Detail?
What is the role of union all and union
What is the use of with ur in db2?
how to unload different table data into different gdg files/ vsam files.
SET is the ANSI standard for variable assignment, SELECT is not. SET can only assign one variable at a time, SELECT can make multiple assignments at once. If assigning from a query, SET can only assign a scalar value. If the query returns multiple values/rows then SET will raise an error. SELECT will assign one of the values to the variable and hide the fact that multiple values were returned (so you'd likely never know why something was going wrong elsewhere - have fun troubleshooting that one) When assigning from a query if there is no value returned then SET will assign NULL, where SELECT will not make the assignment at all (so the variable will not be changed from it's previous value) As far as speed differences - there are no direct differences between SET and SELECT. However SELECT's ability to make multiple assignments in one shot does give it a slight speed advantage over SET.
Lot of updates have been done on a table due to which indexes have gone haywire. What do you do?
What if we try to insert the base table through updatable view , but failed to give a column value which is defined as NOT NULL.