How to divide logic flow stream in sp

Hi, all
I have a call from other app that should return SELECT results with 4 different WHERE clause, depending which set of params caller specifies, and which left like null.
So I need to separate logic in my sp (caller insist on having single sp for all). i.e
procedure sp01( param1=22, param2=33, param3=null, param4=null) ---> SELECT COLUMN_LIST FROM TABLE WHERE COLUMN1=PARAM1 AND COLUMN2=PARAM2;
procedure sp01( param1=null, param2=null, param3='abc', param4=null) ---> SELECT COLUMN_LIST FROM TABLE WHERE COLUMN3=PARAM3;
procedure sp01( param1=null, param2=null, param3=null, param4='xyz') ---> SELECT COLUMN_LIST FROM TABLE WHERE COLUMN4=PARAM4;
etc..
COLUMN_LIST stays the same for all SELECTS just different WHEREs. So beinig new to pl I interesteing how do you think better implement this logic in single sp, can I use any VAR for WHERE ? Or maybe there are some other clever tricks I go with to make it looks sound.
I can think go with number of IFs:
IF (PARAM1 IS NOT NULL ) AND (PARAM2 NOT NULL) THEN
SELECT #1
IF (PARAM2 IS NOT NULL ) THEN
SELECT #2
etc..
Apreciate you comments
Tx
T

Another option (which is not Dynamic SQL).
select <columns>
from table
where (column1 = param1 or param1 is null)
and   (column2 = param2 or param2 is null)
and   (column3 = param3 or param3 is null)
and   (column4 = param4 or param4 is null)Either approach (this or dynamic) could have potential performance drawbacks. It will depend highly on your situation so try them both out (in as real world simulation as you can get) and take some metrics.

Similar Messages

  • How to control logic flow in SQL Plus script

    Hi
    I have the requirement below:
    Before I start running an SQL script, I need to ensure that I am connecting as a particular user. If I am not that user, then the script should show a msg "Error - Invalid User - Log in as <<username>>"
    Let's say i am executing a script A.sql.
    SQL > @<path>a.sql
    But before this script is executed -- i shall check for the user:
    block begins...
    select user into var1 from dual
    if upper(var1) != 'ABCUSER' then
    -- display the error message and stop execution of this script
    else
    @<path>a.sql (*it executes what i want :) )
    end if;
    block ends...
    How do I write this code using an SQL script ? Pls sugges

    Hi,
    As Centinul said, SQL*Plus is poorly equipped to deal with problems like this. If possible, try to do what you want outside of SQL*Plus.
    If you really have to do it in SQL*Plus, here are two ideas:
    (1) run a script conditionally
    (2) deliberately raise an error
    (1) Using SQL*Plus substitution variables, you can decide which of several scripts to run as a sub-script, based on the results of some query.
    For example, if a.sql is the script that only user ABCUSER is allowed to run, then write two other very short scripts:
    (a) warning.sql, such as the following:
    --  warning.sql
    PROMPT  You are not authorized to do this.
    QUIT(b) step_1.sql, which decides whether a.sql or warning.sql should be run, and does it:
    --     step_1.sql - Decide whether a.sql or warning.sql is to be run next, and do it.
    --     (a) decide:
    COLUMN  script_name_col     NEW_VALUE     script_name
    SELECT     CASE
              WHEN  USER = 'ABCUSER'
              THEN  'a.sql'
              ELSE  'warning.sql'
         END     AS script_name_col
    FROM     dual;
    --     do:
    @&script_nameYou may want to use @@, or specify a complete path name.
    (2) Deliberately raise an error, either in a separate script or in a.sql itself, like this:
    WHENEVER     SQLERROR     EXIT
    SELECT     CASE
              WHEN  USER = 'ABCUSER'
              THEN  NULL
              ELSE  TO_NUMBER ('This will raise ORA-01722')
         END     AS "Welcome!"
    FROM     dual;
    WHENEVER     SQLERROR     NONE
    -- continue with the original a.sql

  • How to user netbean to follow java app logic flow

    I imported a j2se application (about 60 classes) into the netbean IDE, I was able to compile and run it. I am new to this program and would like to use netbean to execute this app step by step to follow the logic flow of the program and to understand this program. How do I do that?
    Thanks

    You don't NEED an IDE such as JBuilder, but it does make things a little easier.
    What I'm guessing you have is a bunch of .class files and you want to turn it into something compact and executable, right? The best thing to do is create an executable .jar file. Jar is a type of compressed archive similar to Zips.
    In the JDK, there is a program called jar.exe which you can use to pack your classes into a JAR file. To run a jar file, in the command prompt, or a batch file, simple write "java -jar MyApp.jar". You can also run a Jar file just by doubleclicking it by setting: java.exe "-jar" "%L" in the file types menu in explorer.
    If you have something like JBuilder, you can make it automatically create the Jar file when you build your app.

  • How to redirect loading flow in process chain based on logic?

    Hi Experts,
    I have a scenario where I want to keep data for last 3 years in 3 different cubes.e.g. lets say cube 1 holds data for current 2006 year, cube 2 holds 2005 and cube 3 holds 2004.Now in next year 2007, I want to keep data for 2007, 2006 and 2005.I want to keep data for 2007 in cube 3 which was holding 2004 data.(delete 2004 data and load 2007).
    This process should be automated i.e. which cube to load should be done auto.In short, <b>data for new cube should go into cube which is holding data for oldest year.</b>
    I want to know :
    1) Which Options I can use to do this?
    2) What about ABAP program : custom table can be maintained to know which cube is holding what data, but how to redirect loading flow?
    3) What about "Decision process type" in process chain?
    4) Also would custom process type solve this functionality?
    Any ideas would be highly appreciated.
    Thanks in advance,
    Sorabh

    Hi Sorabh,
    Its just an Idea, Im assuming that this would work. This should also work for INIT DELTA I guess. But would need proper testing.
    Have a Custom Table ZCUBEYEAR and maintain the CUBE as the Key.
    ZCUBEYEAR
    CUBE     YEAR
    Y1       2004
    Y2       2005
    Y3       2006.
    In the update rule->Start Routine for Cube Y1, extract this entry from the table ZCUBEYEAR for Y1, which in this case would be 2004.
    DELETE DATA_PACKAGE WHERE YEAR NE YEARFORCUBEY1.
    in our case YEARFORCUBEY1 = 2004.
    For cube Y2 and Y3 the Delete statement would be as follows in their Start Routines.
    DELETE DATA_PACKAGE WHERE YEAR NE YEARFORCUBEY2.
    DELETE DATA_PACKAGE WHERE YEAR NE YEARFORCUBEY3.
    This would ensure that only 2004 data would flow to Y1, 2005 for Y2 and 2006 for Y3.
    Once we come to a NEW YEAR, We need to run a program or Manually change the CUSTOM TABLE "ZCUBEYEAR" updating the cube Y1 with 2007, the Deltas would flow correctly.
    Please email me at [email protected], we could have a detailed discussion.
    Hope the above helps your cause.
    Regards,
    Praveen.

  • How  to divide an bytearray into chunks in java using streams

    how to divide an bytearray into chunks in java using streams

    i'm trying to read an image using fileinputstream then converting to bytearray after conversion i have to read that image chunk by chunk and write to a outputstream

  • Who knows: How to divide the request.getInputStream()?

    I use a form in a web page to update files, the form code is
    <form action="/Mywork/servlet/fileupdate1" method="post" enctype="multipart/form-data">
    <p>
    Please select a file1 to upload: <input type="file" name="foo">
    </p>
    <p>
    Please select a file2 to upload:<input type="file" name="foo1">
    </p>
    <input type="submit" value="Upload File!">
    </form>
    and the "fileupdate1" servlet which the "action" in the form tag refers to will get the inputstream by
    "ServletInputStream servIn = request.getInputStream();", and create new OutputFileStream in the disk. But
    new files which the servlet stored always have some additional codes "
    -----------------------------7d419320202be
    Content-Disposition: form-data; name="foo"; filename="H:\Documents and
    Settings\administrator\desktop\ee.java"
    Content-Type: application/octet-stream
    If I updating two files, each file will has these kinds of codes and the two files only have one inputstream. I don't
    how to remove these additional codes and how to divide the stream into pieces according to the updated-file-size.
    I don't know wether I say it clearly?And
    does anyone know the reasons and can help me?
    Thank you very much.

    Use something like Jakarta Commons FileUpload to process the multipart/form-data request:
    http://jakarta.apache.org/commons/fileupload/

  • How to divide the request.getInputStream()?

    I use a form in a web page to update files, the form code is
    <form action="/Mywork/servlet/fileupdate1" method="post" enctype="multipart/form-data">
    <p>
    Please select a file1 to upload: <input type="file" name="foo">
    </p>
    <p>
    Please select a file2 to upload:<input type="file" name="foo1">
    </p>
    <input type="submit" value="Upload File!">
    </form>
    and the "fileupdate1" servlet which the "action" in the form tag refers to will get the inputstream by
    "ServletInputStream servIn = request.getInputStream();", and create new OutputFileStream in the disk. But
    new files which the servlet stored always have some additional codes "
    -----------------------------7d419320202be
    Content-Disposition: form-data; name="foo"; filename="H:\Documents and
    Settings\administrator\desktop\ee.java"
    Content-Type: application/octet-stream
    If I updating two files, each file will has these kinds of codes and the two files only have one inputstream. I don't
    how to remove these additional codes and how to divide the stream into pieces according to the updated-file-size.
    I don't know wether I say it clearly?And
    does anyone know the reasons and can help me?
    Thank you very much.

    Well, if you know the format, you'd know that the file data starts after the first blank line (\r\n\r\n).
    But why don't you just use Jakarta Commons File Upload or some other existing free package to handle multipart forms and save yourself the trouble.

  • How to issue cash flow report?

    Hello everybody:
    Can anyone tell me what is the standard method for SAP to issue cash flow report? Is it Cash Budget Management?
    I am using SAP version 470.
    rgds!
    Andy.

    Could you give me more explanation on the logic of SAP how to issue cash flow report?
    Andy

  • How to divide the partitions in AIX 5L

    Hi Guru's
    Friends i am installing AIX 5L, How to divide the partitions in AIX5L
    please tell me if anybody know.
    Thanks

    What kind of partitions do you mean? Do you mean logical partitions?
    Message was edited by:
    Ivan Kartik

  • Logical flow between User forms and workflows

    Hi,
    I want to know the logical flow among jsps,UserForms and workflows in IDM.
    This may appear as a silly quest. But I want to know how exctly the workflows are getting excuted when we click the buttons on the forms....
    For eg While creating the user after gving the user details in Tabbed User form when we click on save how it is calling Create User Workflow....
    where is the link and how its happening.....
    If any one know this please reply me....this a quest remaining in my mind since so many days....
    Thanks in advance....

    I dont think, there is any xml codes in any of the forms for calling workflow. One needs to render a form for any workflow. Whenever you hit new User , the create user workflow gets initiated and the form and the default form for create user is Tabbed User Form. activities and forms are mapped according to the authorisation level. If you create any Admin role, then we need to specify a form for the admin's capabilities. I guess for configurator , to create a a new user, the form has to be Tabbed User Form by default. For a custom Lanch user process, one needs to include a form along with the workflow. We can do that. Thats what I know till date.
    Thanks,
    Manila

  • How to make data flow from one application to other in BPEL.

    Hi All,
    I am designing work-flow of my application through BPEL(JDeveloper), I am making different BPEL projects for different functions, like sales manager got the order from sales person and sales manager either approve it or reject it, if he approve it it goes to Production manager and he ships the goods, now I want to keep sales person, sales manger,production manager in seperate BPEL files and want to get the output of sales person to sales manager and sales manager to production manager please help me in dong this.
    I was trying to make partner link in Sales manager of sales person and getting the input from there. I dont know this is right even or not, if it is right I dont know how to make data flow from one application to other.
    Experience people please guide.
    Sales Person -----> Sales Manager ----> Production Manager
    Thanks
    Yatan

    Yes you can do this.
    If you each integration point to be in different process, you have to create three BPEL process.
    1. Create a Async BPEL process 'A' which will be initiated when sales person creates the order.
    2. From BPEL process 'A' call a ASync BPEL process 'B' which has the approval flow. Depending on the input from process 'A' the sales manager will review the order in workflow and approve or reject and send the result back to process 'A'.
    3. Based on the result from workflow, invoke the Sync BPEL process 'C', where you can implement the shipping logic.
    -Ramana.

  • How to use Logical database in function module?

    I will create a function module in HR.
    but how to use Logical database  in function module ?  Logical database PNP always show screen.in function (RFC) code , it is a matter.

    You cannot attach the LDB to the main program of the function group.
    - So you may [SUBMIT|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=submit&adv=false&sortby=cm_rnd_rankvalue] a report which use the LDB and get back the data (export/import), by default in the syntax of SUBMIT the selection-screen will not be displayed
    - Use [LDB_PROCESS|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=ldb_process&cat=sdn_all], fill a structured table for selection, and get data back in another table
    - Use [HR function modules to read Infotypes|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=hrfunctionmodulestoread+Infotypes&adv=false&sortby=cm_rnd_rankvalue].
    Regards

  • How to determine logical database in a program?

    Hello guys!
    How to determine logical database in a program on Eclipse?
    I have not found any options:
    Thanks!

    Welcome to SDN
    Check the table RSOSFIELDMAP
    Assign points if useful
    Regards
    N Ganesh

  • How to track the flow of Sharepoint SSRS report requests to troubleshoot slowness

    How to track the flow of requests of Integrated SSRS report links in Sharepoint.
    We are using SSRS with Sharepoint for reporting purpose. The issue is some of the reports get generated fast and some other reports generation is very slow. When the sql query of these reports RDL file is executed, the records are shown fast.
    Also even on clicking the "Add Subscription" link of "Manage Subscriptions" of a report is very slow for some reports, while it is fast for other reports.
    I tried enabling SQL profiler to track the requests.  I have checked profiler log for the SQL statements with exec sp_executesql. But they are not helpful.
    Pls advice on how to track the request of flow of SSRS report request in sharepoint and how to troubleshoot the slowness in  "Add Subscription" link, response of some reports.

    Hi Pradeesh,
    According to your description, my understanding is that you want to track SharePoint SSRS report requests to troubleshoot the performance.
    Developer dashboard is very help full while troubleshooting the issues related to performance in SharePoint 2013.  You can have a try.
    About Developer dashboard, you can refer to the links:
    http://www.sharepoint-journey.com/developer-dashboard-in-sharepoint-2013.html
    http://msdn.microsoft.com/en-us/library/office/ff512745(v=office.14).aspx
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • How can I get netflix streaming audio, the video is fine but the audio coming through is from the TV(dish)

    how can I get netflix streaming audio, the video is fine but the audio coming through is from the TV(dish)

    It's exactly as I stated. Whenever I try to drag these kinds of loops (ESX24 / software instrument loops? the ones marked in green with the white music note next to them) from the loop browser into the timeline a message comes up saying Audio Not Found for that loop.  And a new track is created automatically when loops are dragged into the timeline, so I'm not creating some other random / synth instrument track so I'm not sure  what the deal is... But perhaps I'll try creating a software instrument track first and then drag the loop into that track and see what happens - maybe there's something with the default settings that automatically creates audio tracks whenever loops are imported?

Maybe you are looking for

  • Iphone--verizon's lack of customer loyalty

    Existing customers are not eligible to purchase the iphone at promotional price unless they are due for an upgrade.  We do have the option of paying full price for the iphone.  This is clearly a slap in the face to existing Verizon customers. 

  • Storing media on external drive - huge mess

    I recently transferred my complete iTunes library to an external drive, connected over a network. The process went smoothly and there were NO problems. However, after a recent update (I think this was the cause anyway), something isn't right. Now, wh

  • Excise Captured in Base Currency needed in local currency

    Hi All,     In MIGO Excise Capture is done but the Base Currency is coming for BED, AED, ECS and SECess. I need it in local currency. The Base Value is in Local currency. Any thing has to be updated Functionally. Thanks in Advance, Sapuser

  • Default Cost Centre No. in the Settlement Rule

    We have an issue here.  When maintenance orders are settled, a Cost centre ABCD001 is automatically picked up as 'settlemement receiver'.  From where this default Cost Centre number is coming ?  Could you please guide me.

  • Cannot deactivate previous computer to install CS3, now what?

    I am unable to access a previous computer to deactivate Contribute CS3 in order to complete installation on new computer. Any suggestions?