Some times we need a same "SELECT" to select several rows or a row from a table. With this we have to use two instructions, "SELECT" with different conditions of searching in "WHERE".
Example: We use a same "SELECT" instructions:
This SELECT, it obtains from table_1, all fields where fld_date = 2003 year and 01 month.
SELECT *
FROM table_1
WHERE fld_date = 200301
But, what happens when you need only an ID, for the same date (200301)? You can condition the WHERE instruction with... (to see code).
If you aux_ID variable it has some ID valid. You need that specific ID, or you need all IDs.
SELECT fld_id, fld_name, fld_lastname, fld_date, .....
FROM table_1
WHERE fld_date = 200301 AND
fld_id = CASE
WHEN :aux_id > 0
THEN aux_id
ELSE fld_id
END
================================== MORE INFORMATION ON THIS TOPIC ==================================
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.
This was first published in January 2003