Conditionally apply AND condition

CREATE OR REPLACE PROCEDURE SP_TFS_REPORT (LoginId IN STRING,
status IN STRING,
fromAmount IN STRING DEFAULT NULL,
toAmount IN STRING DEFAULT NULL,
accNumber IN STRING,
result_cursor OUT SYS_REFCURSOR)
IS
BEGIN
OPEN result_cursor FOR SELECT * FROM TEST_TABLE T1
WHERE T1.LOGIN_ID = LoginId AND
T1.STATUS = status AND
T1.FROM_AMOUNT >= to_number(fromAmount) AND --This needs to be applied only if fromAmount paramter is not null*
T1.TO_AMOUNT <= to_number(toAmount) AND --This needs to be applied only if fromAmount paramter is not null*
T1.ACCOUNTNUMBER = accNumber;
COMMIT;
As you can see 'fromAmount' and 'toAmount' are optional paramters to the stored procedure. So the AND conditions corresponding to them need to be conditionally applied. In other words they need to be applied only when I get a NOT NULL value.
I know we can do this using IF ELSE condition but is there any efficient way to do this?
My DB details are:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
Thanks in advance for any help!!

Hi,
Sure, you can use CASE in a WHERE clause, but there's usually no benefit in doing so.
Why not
WHERE   T1.LOGIN_ID     = LoginId
AND     T1.STATUS      = status
AND     T1.FROMAMOUNT      >= nvl ( to_number (l_fromAmount1)
                           , T1.FROMAMOUNT
AND     T1.FROMAMOUNT   <= nvl ( to_number (l_fromAmount2)
                            , T1.FROMAMOUNT
AND     T1.ACCOUNTNUMBER = accNumber; ?
This assumes t1.fromamount is not NULL.
It looks like you've changed your requirements: earlier, you were interested in t1.from_amount and t1.to_amount, and now only t1.fromamount.

Similar Messages

  • FRM-40400: Transaction complete: 1 records applied and saved

    Dear All,
    Hope all of you are doing well,
    Pls go through my problem...
    here is an application developed based on Oracle Forms & Reports 6i.
    I wrote a code, like for some specific Users, various permissions.
    Ex: User A (Payroll Person), User B (HR)
    for employee Master Data HR is the right person to modify master data and all the remain are not permissible.
    I query one person (from Non HR user), try to modify Master Data  then it given user defined message -
    "you are not authorized person to modify Master Data" [OK] - so no changes done
    then I clicked the Query button directly,
    it gave the message - "Do you want to save the changes you have made"  [Yes] [No] [Cancel]
    when I clicked Yes :
    " FRM - 40400 : Transaction complete : 1 records applied and saved "
    In database also it is saving the record..
    Mean for unotherised user also It's modifying the data.
    Please help me the way to handle this issue..
    Thanks in Advance...

    As salamualikum, Md Sirajoddin
    You wrote
    I query one person (from Non HR user), try to modify Master Data  then it given user defined message -
    "you are not authorized person to modify Master Data" [OK] - so no changes done
    That means your code works in some condition. Right ?
    Place your code at Pre-Commit trigger at form level.
    Hope this helps
    Hamid

  • Can I homeshare my music with somebody not on my home network by providing my applied and password in the setup for homesharing

    can I homeshare my music with somebody not on my home network by providing my applied and password in the setup for homesharing

    Yes, you can install and use the software on the 2nd machine so long your new company owns the license, the software is used but the same person who is using the primary installation (that is, you).

  • HT201317 Photostream to my Windows computer has stopped working. In icloud control panel, photostream is unchecked, I check it, hit options, nothing happens. I click apply and close. Next time I  open control panel, photostream is unchecked again! What ca

    Photostream to my Windows 7 computer has stopped working. When I open icloud control panel, photostream has become unchecked even though it has been previously checked. I check it again but when I click options, nothing happens. I click apply and close, but next time I open the control panel, Photostream has become unchecked again. What can I do?

    Lisaglenoak:
    When I first downloaded iCloud to my PC a little while back, Photo Stream initially worked. I was able to check/uncheck both boxes available to me, as well as click the Options tab to the right of Photo Stream. I could make changes, click "Apply", and everything was fine and dandy.
    Within a day, I opened the iCloud Control Panel, and despite how many times I would uncheck Bookmarks, it didn't matter. I would click "Apply", and it would automatically ask me to sign in again. When I did this, Bookmarks would be checked again. Additionally, Photo Stream was grayed out; I was unable to check the box (which was unchecked), and I was unable to go to Options.
    Somehow, I managed to get my iCloud Control Panel "unstuck", and currently, it is working fine. There are 2 steps that I did to accomplish this. The 1st step listed below may be the crucial element for those whose reinstallation of the program has not succeeded, in and of itself. It is a change that I haven't come across as a possible part of a solution to this problem; I just happened to stumble upon this whilst searching my PC for possible fixes to the problem.
    Step 1: Find your iCloud File Folder. (On my PC, I clicked the Start button in the lower left corner, then clicked All Programs, and finally scrolled down to where all the folders for various "things" are.) Click the Folder and a sub-list will appear, with items such as Calendar, Mail, etc. Right-Click the iCloud Program icon, and at the bottom of the list that appears, click on Properties. At the top, there are 5 tabs. Click the Compatibility tab, and you should see, at the top, the following words: "If you have problems with this program and it worked correctly on an earlier version of Windows, select the compatibility mode that matches that earlier version." Following these words is a dropbox underneath "Compatibility Mode", and for some reason - I have no idea why this is - the box was initially checked to run the program in compatibility mode for "Windows XP (Service Pack 2)". (And from what I understand, Windows XP is not a compatible Windows Edition for iCloud, so I have no idea why this box was checked.) If the box underneath "Compatibility Mode" is checked, than it is running iCloud in compatibility mode for any number of earlier Windows' Editions. Uncheck this box, click the "Apply" button, and then click "OK".
    Step 2: Find your PC's Control Panel. (On my PC, I clicked the Start button in the lower left corner, and then clicked Control Panel in the list to the right.) In the Control Panel, click Programs. Under Programs and Features, Click "Uninstall a program" (and bear with me here, because you are actually not going to uninstall iCloud). Now, scroll down the list and find "iCloud". Double-click the "iCloud" icon, and a panel with 2 options should appear: "Repair" and "Remove". Check the "Repair" box, which will reinstall the same iCloud Control Panel, replacing missing or damaged files. ("Remove" will just .. well ... remove iCloud from the computer - or, if you prefer, uninstall the program.) Click Next, and the repairing process will begin and end. And that is it - you're done. Task Completed.
    Well, in the end, this worked for me. Photo Stream was no longer grayed out. I could permanently uncheck Bookmarks (finally). The Options tab for Photo Stream would open. Anytime that I clicked the "Apply" button after checking/unchecking boxes, it wouldn't ask me to sign in again (only to come back to a Control Panel that looked just like it did before I made any changes to it.). And, I created a Shared Photo Stream on my phone using photos from my Camera Roll (to test the program), and the Shared Photo Stream appeared on my PC's Photo Stream in no time. Hopefully, this will work for you too (regardless of the Windows Edition you are currently using).     ~ Brian

  • Apply and delete buttons need differentiation

    How do we get the apply and delete buttons put in different locations on the info window for ical? I've accidentally deleted when I meant apply because the buttons are in the same location. Mabye delete should be at the top right.

    Richard,
    That sounds like a great idea. Be sure to submit iCal Feedback.
    In the meantime, don't forget about the iCal>Edit>Undo menu command (⌘Z).

  • How are labels applied and referenced (they are mentioned in Preferences)

    How are labels applied and referenced (they are mentioned in Preferences)?

    I searched Help for "labels" and found only one reference - to Preferences, seemingly the only place the plural is used. I needed to search for "label" instead.
    I agree the documentation is good, but IMHO, it is not a User Manual; it is a product Reference Guide. The software (A3 especially) is very flexible and comprehensive, so it is very difficult to use it in a workflow, as it will support many different approaches both to organizing pictures and editing them. I can understand why Apple does not document this for photograpers. IMHO they carry this to a bit of an extreme - even their Adjustments are not listed in a logical (to me) sequence. I hope I can adjust this. The Library needs careful planning, and there are no guidelines on how to organize it, just lots of description of its myriad features.
    I too use labels to document my progress through my workflow. FYI, here is my old list. I used a different editor for my RAW pictures, and used Aperture to organize finished JPG's only. I'm changing that now, trying to make life simpler. so the process will change. My import software defaulted all pictures to 'maybe' (orange), and my first step was to cull them to bad (red) or selected (yellow) for further editing. However, the label data is stored in different fields by the two manufacturers, so another reason to change.
    Thanks for your help
    Bad
    Maybe
    Selected
    Developed
    Adjusted (to a finished quality)
    More (special) editing in progress
    Good, can create a JPG for Aperture
    Good and in Aperture
    Hold for whatever reason
    Cheers Bill

  • Resolution will not stay put, changes at turn on after selecting "apply and ok"

    When I set the resolution on display settings to the max on the slider scale, then select apply and ok and select to keep this setting, every thing works as it should until I shut down and restart the laptop.Upon restart or startup, the resolution goes back to a lower resolution and all is distorted, then I have to go back into control panel, personalizing, display settings and reset the resolution to max. This happens almost 100% of the time but not always. Very annoying behavior..
     Any help would be appreciated to keep the resolution set and stop this tiring/annoying routine
     System is Vista..
    Chuck

    Try placing the iPhone into recovery mode.
    If this is successful, this will require restoring the iPhone with iTunes. Do so as a new iPhone or not from the iPhone's backup.
    http://support.apple.com/kb/HT1808?viewlocale=en_US

  • Since I updated to latest software on ipad cannot sync. with computer.  Makes it to step 7 however says 'waiting for changes to be applied' and never completes sync.

    Since I updated to latest software on ipad cannot sync. with computer.  Makes it to step 7 however says 'waiting for changes to be applied' and never completes sync.
    thx for the help,
    Tony

    Hello Marcia,
    Sorry you are having trouble syncing content with your iPhone 5. I found an article that might help with this syncing issue:
    iTunes: May become unresponsive when connecting iPhone, iPad, or iPod touch
    http://support.apple.com/kb/TS3219
    Also, you can delete the songs from the iPhone without syncing by just swiping from left to right over the song to get a delete button. 
    I hope this helps!
    Best,
    Sheila M.

  • Do i have to click both apply and save?

    easy question.
    some times when making changes in the settings of my e2000 and just clicking apply, the setting doesn't stick.
    when i first flashed router with dd-wrt and tried saving the correct time/time zone, it wouldn't stick even when clicking apply AND save. had to do it a couple times to make it stick.
    shouldn't just clicking apply, make the change stick?
    thank you

    try and clear your cache then if it would appear as such.
    pardon me but i think your question should be directed at the dd-wrt page since that is where the firmware came from.
    but more likely it is just a cached page problem unless you get the same result from other computers in the network.

  • When connecting my iphone to the computer all goaes well on the sync (ing) is that when its finished I have a message that itunes is waiting for changes to be applied and the programme will not finish the complete sync!! any answers please.

    When connecting my iphone to the computer, all goes well with the sync until the last step. Step 6. It says "waiting for changes to be applied" and won't complete the sync!! anyone know how to rectify.

    I'm having the exact same problem.  Using iTunes 1.1.5, iPhone 5 which is updated. 
    Computer is running OS X version 10.9.2

  • Am I able to assign different lists of favourites to different Locations in Mac OSX 10.6? (ie, my work favs when work network settings applied and home favs appear when home network settings applied?)

    # Question
    am I able to assign different lists of favourites to different Locations in Mac OSX 10.6? (ie, my work favs when work network settings applied and home favs appear when home network settings applied?

    The local firewall is off out of the box.
    The log on the Netscreen shows nothing out of the ordinary. Shows the connections being established then closed.
    Support for the firewall is long gone.
    I can try calling Apple but I do not look forward to that call just to be told the firewall is at fault and there is nothing they can do about it.

  • Whenever i try to manually sync my iPhone with a new playlist on iTunes (on my laptop), it always gets stuck in step 7, Waiting for changes to be applied, and then nothing happens. I'm running the latest operating systems on both my iPhone 5 and macbook

    Whenever i try to manually sync my iPhone with a new playlist on iTunes (on my laptop), it always gets stuck in step 7, Waiting for changes to be applied, and then nothing happens. I'm running the latest operating systems on both my iPhone 5 and macbook

    I really don't appreciate the fact that no one from Apple seems to be dealing with the many, many threads that have started on this topic since iOS 7 came out. In any event, I seem to have solved my problem with a full software restoration -- that is, iOS software restoration.
    I clicked on "Restore iPhone..." which does a complete reinstall of the iOS but also all apps, photos, songs, etc. Took about 45 minutes, but seems to have worked.
    I had previously tried reverting to a backup of my iPhone, but that did not solve the problem. Only a full restore solved it.

  • DMV use Cross Apply and too much result

    Hi
    Here are my code for query DMV, but some column Is repeated, how can I filter it (last_exection_time) ?
    I just wnat find T-SQL query information(only select), and it must include query text、targert db、source application(from connection string )、and other needed !
    You can change database name and where conditional, for your testing ! Thanks
    SELECT DB_NAME(DMV_QueryText.dbid) as 'DBName',
    DMV_Sessions.program_name as 'ApplicationName',
    DMV_QueryText.text as 'SQL Statement',
    execution_count as 'Count',
    --last_rows, (for SQL 2012 only)
    last_execution_time as 'Last Execution Time(ms)',
    last_worker_time as 'Last Worker Time(ms)',
    last_physical_reads as 'Last Physical Reads(ms)',
    last_logical_reads as 'Last Logical Reads(ms)',
    last_logical_writes as 'Last Logical Writes(ms)',
    last_elapsed_time as 'Last Elapsed Time(ms)'
    FROM sys.dm_exec_query_stats AS DMV_QueryStats
    CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS DMV_QueryText
    cross Apply sys.dm_exec_sessions as DMV_Sessions
    WHERE DMV_QueryText.objectid is null and DB_Name(DMV_QueryText.dbid)='YourDB' and PatIndex('select %',DMV_QueryText.text)>0
    and DMV_Sessions.program_name is not null and DMV_Sessions.program_name in('app1','app2','app3','app4')
    -- order by DMV_QueryStats.execution_count desc
    order by DMV_QueryStats.last_worker_time desc
    my407sw

    There is no relationship between sys.dm_exec_query_stats and
    sys.dm_exec_sessions and thus you are getting a Cartesian product, every combination of query stat record and session.
    sys.dm_exec_sessions shows the "aggregate performance statistics for cached query plans in SQL Server 2012"
    http://msdn.microsoft.com/en-us/library/ms189741.aspx and is not tied in any way to a session.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • When syncing after recent update, sync is stuck at "Step 4 of 4" "Waiting for changes to be applied" and will not complete, even after hours.  How can this be fixed?

    I completed the most recent software update for both iTunes and iPhone recently.  I am now trying to sync my iPhone to add newly purchased audiobooks and the sync remains stuck at "Step 4 of 4" with the message "Waiting for changes to be applied"  I have tried everything to correct this.  When sync is cancelled a failure to sync message is generated.  Any ideas????

    Alright, so I reset my computer and suddenly it then recovered. Other times it wouldn't recover after resetting the computer, so I have no idea how it happened. I just restarted the computer lots of time and finally it worked.
    Okay, back to square one. Now to transfer music, I tried my previous acknowledgable solutions but they didn't work. The iPod touch does not feature a hard-disk mode, and windows media player doesn't support iPods.
    I've tried multiple programs to transfer music but none of them work properly and keep giving me error codes. So my iPod still gets stuck at Step 4: Waiting for changes to be applied or whatever it said.
    Thanks in advance ._. (Please help)
    p.s - Apple is useless. If I don't get steady answers tomorrow I'm going to end up calling them and get this problem fixed first hand. Second hand? I don't know, over the **** phone.
    juiceb0xk signing out for the night. Bye. >:(

  • "Apply" and "Sync" buttons not working in the iPod summary...?

    I had just previously purchased a few tv episodes and movies through the iTunes store. Before I had done this, in the iPod summary when connected, I chose which movies to sync to my iPod instead of syncing all of them. Now when I go to check the boxes next to the new movies/episodes, and press apply, they do not sync and I just get a message saying that "the disk cannot be found." I do not understand why it is doing this because I can sync all of my other music and podcast files fine. If someone would help me with this problem I would be eternally grateful.

    - You can try resetting the iPod
    - Restoring the IPod via iTunes
    You might get more detailed responses if you posed in the iPod Nano forum.  You posted in the iPod Touch forum.

Maybe you are looking for