I need assistance on setting lexical in cursor

Dear Experts,

Hope you will be fine.

I'm using oracle DB 10.1.2 and formulas 10.1.2.3. I want to write a cursor where "some where condition" can exist or not exist.

As below are the main SQL cursor.

SELECT TEMP_DATA
FROM TAB1
WHERE BDATE BETWEEN :B_DATE AND :E_DATE
AND DEPT_ID=:P1
AND DIVM_ID=:P2
ORDER BY BDATE;

Here, I want to, the user can change the value in P1, P2 or one or none. More information. B_DATE and E_DATE must be entered by the user and

If the user passes both the value of P1 and P2 the sql above is ok for the cursor. But if the user spends not the worth of P1 then shouldn't like sql cursor

SELECT TEMP_DATA
FROM TAB1
WHERE BDATE BETWEEN :B_DATE AND :E_DATE
AND DIVM_ID=:P2
ORDER BY BDATE;

How to do this in a slider?

Thanks for your time.

Ask2Learn

Hello

You can write the SQL code as below...

SELECT TEMP_DATA
FROM TAB1
WHERE BDATE BETWEEN :B_DATE AND :E_DATE
AND (DEPT_ID=:P1 OR :P1 is NULL)
AND (DIVM_ID=:P2 OR :P2 is NULL)
ORDER BY BDATE;

This way if P1 is not entered by the user, then it will be null (same for the P2).

I hope this helps.

VR,

Sudhakar

Tags: Database

Similar Questions

Maybe you are looking for

  • The Rams - EE of Compaq Presario CQ60-116 upgrade

    Hello This is my first post so I think I erased my point of view, which may not be 100% good. In any case, short story... I have a Compaq Presario CQ60 - 116 EAhttp://support.HP.com/us-en/document/c00820047and I would like to upgrade of his memory, I

  • OpenGL on Stream 13-c110ca laptop HP?

    I can't seem to find which version of OpenGL stream HP 13-c110ca supports - anyone know? Thank you.

  • Download Windows Mail problem

    During my good computer for the service, I have created an e-mail account on a Toshiba laptop under Vista Home and Windows Mail, what email client I've ever used before.  I have a slow connection, so I normally go to the site of the ISP and organize

  • The sides of the screen are cut

    * Sorry if I have errors of language *. I bought a new PC with Windows 7 64 BIT (video card - AMD Radeon HD 7800) If I put the 1920 X 1080 resolution, the screen looks blurry and the quality is very poor and there are black lines on the edges. If I p

  • Unable to set the values in the effects with wacom pen Panel.

    I just upgraded to 2015.4. When you use the cursor to the values of the slide in the effect controls panel, nothing happens. The hand cursor disappears and the value pointed out that requires a typed value to insert. The slider works Ok, but is slowe