Conditional WHERE clause based on the input of parameter

When the restriction of data based on a parameter I generally use the following syntax:

AND p.start_date = NVL (p_start_date, p.start_date)

so IF the parameter is null, THEN I join only on itself, OTHERWISE we filter on parameter.

New requirement means greater than or equal to, so I tried this:

AND THE CASE
WHERE (p_start_date = NULL) THEN
p.start_date = p.start_date
ON THE OTHER
p.start_date > = p_start_date
END;

but, at least, is syntactically incorrect.

Any suggestions?

Thank you!

Do not use = with NULL - change IS null

Tags: Database

Similar Questions

  • dynamic logic in SQL WHERE clause based on the value of the ELEMENT

    Hello

    I have a report based on the following SQL query.
       select dept_no,
           dept_name,
           dept_loc
      from dept
     where dept_loc = :P1_DEPT_LOC
       // If P1_DEPT_LOC is not null, I want the WHERE clause and IF  P1_DEPT_LOC is null, then I don't need the WHERE clause.
       // how can I build this logic in same SQL
    Thank you
    Deepak

    Published by: Deepak_J on March 11, 2010 16:37

    where: P1_DEPT_LOC IS NULL or dept_loc =: P1_DEPT_LOC

    If dept_loc is not null better would be

    where dept_loc = coalesce(:P1_DEPT_LOC,dept_loc)

  • Where conditional Clause based on the length of the field

    Hello people,
    I tried to search for this scenario in OTN and not been able to find any success so I will post the question here.

    I have two tables - with the detail records and the other being a table of codes. I need to join these two tables based on the code and the length of the code. Let me explain using examples.

    Scripts for creating the table and inserts
    create table ILLNESS_CODES(illness_code varchar2(4), illness_description varchar2(100));
    create table PATIENT_TB(patient_id varchar2(4), primary_cause varchar2(4));
    
    insert into illness_codes values('B10', 'Flu');
    insert into illness_codes values('B30', 'Hepatitis');
    insert into illness_codes values('B301', 'Hepatitis A');
    insert into illness_codes values('B302', 'Hepatitis B');
    insert into illness_codes values('B303', 'Hepatitis C');
    
    insert into patient_tb values ('1001', 'B101');
    insert into patient_tb values ('1002', 'B102');
    insert into patient_tb values ('1003', 'B30');
    insert into patient_tb values ('1004', 'B301');
    insert into patient_tb values ('1005', 'B302');
    insert into patient_tb values ('1006', 'B302');
    insert into patient_tb values ('1007', 'B303');
    insert into patient_tb values ('1008', 'B30');
    As you can see that patients * 1001 * and * 1002 * have no codes in the Master table. In this case, I want only the first 3 characters of the ILLNESS_CODES table.
    However, for B30, it has a Code and the same for B301, B302 B303 where I would meet the description based on the exact code.

    Example of output
    Patient ID   Illness Description
    =====================================
    1001         Flu
    1002         Flu
    1003         Hepatitis
    1004         Hepatitis A
    1005         Hepatitis B
    1006         Hepatitis B
    1007         Hepatitis C
    1008         Hepatitis
    Thanks in advance!
    SELECT p.*,
           NVL ( (SELECT illness_description
                    FROM ILLNESS_CODES I
                   WHERE i.illness_code = p.primary_cause),
                (SELECT illness_description
                   FROM ILLNESS_CODES I
                  WHERE i.illness_code = SUBSTR (p.primary_cause, 1, 3)))
      FROM PATIENT_TB p;
    
  • How to conditionally display images based on the values of the variables

    I am building a demonstration Captivate containing a slide branching that allows the user to choose which way they want to view; Once they are done, they come back on this slide branching, and I want a check mark to display the button/path that they have already completed.

    I'm new to the use of variables and actionscript in Captivate, so I went the the documentation and the creation of variable is clear, as well as the use of conditional constructions, but I didn't know the instructions of scripts that look like they will allow me to display an image from the library when she is called in the conditional.

    Is this possible? If so, a pointer to an appropriate documentation or sample code would be greatly appreciated.

    Thank you

    Josh

    Hello

    When you insert images of the box, you click the Options tab and give the image a name that you may recognize. Then clear the Visible check box. This allows to keep hidden until you want to show it.

    However, note that even if all the image names are listed in the dialog box advanced Actions as being available for show, you will only be able to show an image if you run the fast Action of the blade where the image exists. So you will likely build a means by which you are setting up a variable to indicate that a section has been visited. Then create an action that is performed on slide enter to show the images based on the values of the variables.

    See you soon... Rick

    Useful and practical links

    Captivate wish form/Bug report form

    Certified Adobe Captivate training

    SorcerStone blog

    Captivate eBooks

  • Change the structure of program based on the input file

    I have a program that takes parameters of an input file and then executes a Visual acquisition, using IMAQ, controlling some other hardware at the same time.  The duration of the various stages of this process control settings.

    There is a sequence stacked structure to control the playback of the input file, the initialization of the hardware, and then a while loop on the last image to actual purchase.

    The user of the program now wish to have several games acquisition in the same race, possibly with different time settings.  This would mean different iterations of the final loop, based on the parameters of the input file.  There could be 5 games of acquisition on occasion, 3 on another, etc., in a performance of the program.

    The structure VI already seems a little baroque, and I don't want to make it even more complicated.

    I would appreciate advice on how best to proceed, because I'm really a novice of LabView.

    If you use a "State Machine" architecture, you can do exactly that.

    Instead of having a structure of stacked sequence, it is essentially a case structure in a while loop.

    Each case represents a State.

    So in your case, you would have a State for:

    -reading the input file

    -initialization of hardware

    -data acquisition

    You can have the user controls the number of iterations of the State for the acquisition of data that you want to run.

  • where clause to query the hierarchy in the tree Apex area does not

    Hi all

    I am building a tree Menu in Apex 5.0.3 (Oracle 11 g XE), when using when the clause, it does show all the data, but without him, showing all the data.

    I'm trying to populate Tree Menu with data specific to a user successfully logged on.

    (A) table created as HR2. TREE_MENU

    menu_name varchar2 (50).

    number of menu_parent

    number of menu_child

    menu_id varchar2 (12),

    menu_path varchar2 (100),

    number of user_no

    (B) SQL statement for the tree in the Apex region

    Select case when connect_by_isleaf = 1 then 0

    When level = 1 then 1

    else                           -1

    end the status,

    level,

    'Menu_name' as the title,

    NULL as an icon,

    "MENU_CHILD" as a value.

    NULL as ToolTip,

    NULL as link

    to HR2. "" TREE_MENU ".

    -WHERE USER_NO =: P_USERNO

    Start with 'MENU_CHILD' is null

    connect prior "MENU_PARENT" = "MENU_CHILD."

    brothers and sisters of order by 'MENU_ID '.

    Note: also used static value where clause but is not workd.

    that the mistake of me or something else? When using the wizard, she asks (possibly) where clause, this means that when the clause can be used in the SQL statement.

    Help, please.

    Kind regards.

    If you want to prune your tree to show only the elements of the No. 7 usermenu, copy the following code helps you

    select case when connect_by_isleaf = 1 then 0
                when level = 1             then 1
                else                           -1
           end as status,
           level,
           "MENU_NAME" as title,
           null as icon,
           "MENU_CHILD" as value,
           null as tooltip,
           null as link
    from HR2."TREE_MENU"
    start with "MENU_CHILD" is null
    connect by
        prior "MENU_PARENT" = "MENU_CHILD"
        and "USER_NO" = 7
    order siblings by "MENU_ID"
    

    Concerning

    Mahmoud

  • Workflow based on the input parameter

    I use JDev 11.1.1.6.

    I have an application that uses a workflow with 'ExecuteWithParams' to get the parameter from a URL and display the records on a page.

    I have it using a Bind Variable on the VO that corresponds to the InputParameter on the control ExecuteWithParams.
    What I would like to make is the flow to another page, depending on the parameter used in the URL.

    Example:

    If param in the URL is '? TEAM = 1 "then I go to the TEAM page and display records for TEAM 1.

    If param in the URL is '? REGION = 3 "then I would go to the REGION page and display records for REGION 3.

    Thank you
    Ray

    This could probably be resolved using a router activity or a custom default activity in the workflow method. Then from the method/router, can easily get to the desired activity of the TF based on an input parameter. For example if the parameter is route 'region' to executeRegionIteratorWithParams, which, in turn, can "go" to view displayRegions activity.

  • Navigation based on the input textfield value?

    Hi all.

    I use Captivate4. In my project, I would like to navigate from one slide to another slide based on the value entered in the input textfield (as if as a drop down menu).

    slide1.jpg

    The image shows, if the user enters the values, it must navigate to slides respectively. So, I got a tip in this way action.

    actions-dialog.jpg

    Hello

    Welcome to the Adobe Forums,

    In order to reach the workflow that you specified in your post that you need several "check if ' for all defined slides the tip on the button click Action.

    For Ex.

    For "a" TI will look like this:

    Because if "two" will look like this:

    Rest allows you to change the variable, just make sure that these all will be on this same script for a button

    It could be useful!

    Thank you

    Vikram

  • Dynamic creation of a control based on the input

    Hello

    Is it possible to change a control on the front panel?

    If the entry is a string I want to show a string. If the input is an integer, I want to show a cursor for example.

    I have a plan to implement on the different tabs and display the tab which must be shown, but maybe there's a faster, easier way?

    Thanks for the help!

    Kim

    Hi Kim,

    Thanks for the additional info.

    The dll and its manual to define what can be output and that's why you need to refer to the manual.

    When you call a dll in LabVIEW, you must set the parameters of static output and so data cannot be of a type for example if set it as a table, it will always be a table. This look for the 'node of function call' in the range of functions-> connectivity-> libraries & Executeables.

  • Loop of work based on the input (as if... else) variables

    HI friends,

    This is my first, if I'm not following all the rules excuse and say to those.

    I want to use the loop for based on the variable passed.

    Under code is wrong, but you can understand my intention.

    CREATE OR REPLACE PROCEDURE sp_pins_deactivation)

    pi_prepaidcard_no IN STR2048_TBLTYP, - Table type

    pi_from_range IN VARCHAR2,

    pi_to_range in NUMBERS)

    Start

    IF pi_from_range is not null and pi_to_range is not null

    THEN

    I'm in pi_from_range... pi_to_range

    LOOP

    ON THE OTHER

    I'm in pi_from_range... pi_to_range

    LOOP

    END IF;

    .......................

    .....................

    ..............

    END LOOP;

    end sp_pins_deactivation;

    create or replace procedure nTtest (nT nTable, start_val number: = null, end_val number: = null) is

    Start

    I'm in coalesce (start_val, nT.first, 1)... COALESCE(end_val,NT.) Last, 10)

    loop

    dbms_output.put_line (I |) ': ' || (-case when nT.exists (i) and (i) nt end of another "no entry");

    end loop;

    end;

    /

  • How to change a region title based on the input parameter?

    Hi all

    I need to change the title of the dynamic region based on the value of a selection list in another region.

    Can someone help me in this?

    Kind regards
    Santini.

    Hello

    You can use & P1_ITEM_NAME. (including the & and the.) the title of region - this string will be replaced by the value of the item page called P1_ITEM_NAME, then change the name according to your order of the day of the page

    Andy

  • Filling of textfield based on the input of another textfield

    Hi guys,.

    I have a problem.

    I have a textfield and the input of information in which must be completed in antother textfield. It seems easy, but the trick is. For each new entry a new textfield should appear with this information. My problem is that it creates a textfield, but for every letter I type in and not to a string when I press ENTER.

    See attached example.

    I hope you can help me!

    Thank you

    Diana

    This is the code: (I can't reach the example for some reason any) Table_SF._Repeat_SF.addInstance (1); xfa.resolveNode "(Table_SF. ("Repeat_SF [" + (Table_SF._Repeat_SF.count - 1) + ' "] '). TextField1.rawValue = xfa.event.newText;

    Instead of placing the code in the event changes, copy it to the Exit event.

    Table_SF._Repeat_SF.addInstance (1);

    xfa.resolveNode "(Table_SF. ("Repeat_SF [" + (Table_SF._Repeat_SF.count - 1) + ' "] '). TextField1.rawValue = this.rawValue;

    Thank you

    Srini

  • order by clause based on the value of the parameter

    Hello

    I use reports 6i with db 10 g

    I need to create a report sorted in the order of four fields. There is a field selection parameter which should come first in the order by clause.

    IE the user has available to display the report in a sorted order selected

    Assume that the four fields are emp_id, name, dept_id desig.

    If the user selects dept_id, then the order by clause should be in order of dept_id emp_id, name, desig

    Please help solve this scenario.

    Thank you

    Hi Clement,.

    Use the query as follows:

    select column_name1, column_name1, ....
    from  table_name
    &order_by_clause
    

    Now in the trigger AFTER-PARAMETER-SHAPE has the order by clause below according to requirements:

    if :sort_column = dept_id then
    
      :order_by_clause := 'order by dept_id,emp_id,name,desig';
    
    else
    
      :order_by_clause := 'order by emp_id, dept_id, name,desig';
    
    end if;
     
    

    Here's sort_column setting user who will be selected by the user, provide the list of values for it.

    Hope this helps

    Best regards

    Arif Khadas

  • Problem with the input CLOB parameter

    Hello to all, I have a requirement where I need to create a query dynamically to insert data into a table that has a CLOB column. Here it comes when the input value is too long oracle gives me ORA-01704: string literal error too long even though I declared a variable CLOB (LS_sql). Same procedure works fine when the insert statement is not dynamic in nature. If I have to dynamically can someone please suggest me some options. Please see my examples below.

    CREATE TABLE NOTES_TEST(NOTE_TEXT CLOB);
    
    
    --Dynamic SQL throws error
    CREATE OR REPLACE PROCEDURE NOTES_INSERT
    (
           IP_note_text         IN    CLOB
    )
    AS
    LS_sql CLOB;
    BEGIN
    LS_sql := 'INSERT INTO NOTES_TEST(NOTE_TEXT) VALUES('||IP_note_text||')';
    
      EXECUTE IMMEDIATE LS_SQL;
    
    END NOTES_INSERT;
    /
    
    
    --Static SQL
    CREATE OR REPLACE PROCEDURE NOTES_INSERT1
    (
           IP_note_text         IN    CLOB
    )
    AS
    
    
    BEGIN
    INSERT INTO NOTES_TEST(NOTE_TEXT) VALUES(IP_note_text);
    
    
    
    END NOTES_INSERT1;
    /
    
    

    Thank you

    Shiva.

    You can (and should) skip the clob as a variable binding to help immediate execution clause.

  • How to pass the parameter in where clause contained in the custom file?

    I have the tracking query

    Blue are the parameters

    I paste this to a custom folder

    and

    Select last_update_date, creation_date

    of ra_customer_trx_all

    "where trunc (last_update_date) = 29-SEP-2012."

    and customer_trx_id = 1109

    in another folder custom return 1 row only and create a different worksheet in the same workbook and create

    3 setting and 2 of them pointing to the 1 row to query and create a calcualtion

    SET_CONTEXT ("Date_From", TO_CHAR(:Date From)) and SET_CONTEXT ('Date_TO', TO_CHAR(:Date To))

    and 1 condition 1 = SET_PARAM3(:Period)

    but this does not work for me, no data back please help

    Select m.party_name TENANT_NAME

    b.interface_line_attribute10 lease_num

    -, b.interface_line_attribute12 «PPS Number.

    b.interface_line_attribute2 LOCATION_CODE

    flexv.description property_name

    INVOICE_NUMBER a2.trx_number

    -, t.nom "Type of Transaction".

    -, e.attribute15 "AS400 Key."

    , b2.description 'BILL_ITEM_INVOCIE_DESCRIPTION '.

    , case when gcc.segment5 like 6% ' then ' P/L '.

    When gcc.segment5 like 7% ' then ' P/L '.

    When gcc.segment5 as 8% ' then ' P/L '.

    When gcc.segment5 like 9% ' then ' P/L '.

    else "B/S".

    end as account_nature

    -, gcc.concatenated_segments as 'account of burden '.

    gcc.segment1 company_code

    gcc.segment2 department_code

    gcc.segment3 property_code

    gcc.segment4 business_segment

    gcc.segment5 account_code

    gcc.segment6 project_code

    gcc.segment7 intercom_code

    gcc.segment8 spare1

    gcc.segment9 spare2

    b2.extended_amount BILL_ITEM_INVOICE_AMOUNT

    to_char (substr(ps.gl_date,4,8)) gl_period

    b.interface_line_attribute11 bill_start_date

    b.interface_line_attribute14 bill_end_date

    decode (a2.invoicing_rule_id, '-2',

    DECODE (TO_CHAR ("b.RULE_START_DATE, ' YYYYMM"), to_char (to_date (to_char (TRUNC (to_date (SETPARAM.) GET_PARAM3, "YYYYMM"), 'Month')-1), "MON-DD-YYYY"), "YYYYMM"), "Current", "Forward").

    'In progress' Bill_nature)

    , to_char (a2.trx_date, ' MON-DD-YYYY "") invoice_date

    pal.lease_commencement_date

    pal.lease_termination_date

    h.user_name created_by

    -, NULL as remarks

    of ra_customer_trx_all one

    ra_customer_trx_lines_all b

    pn_leases_all d

    e pn_tenancies_all

    hz_cust_accounts l

    hz_parties m

    fnd_user h

    ar_payment_schedules_all ps

    RA_CUST_TRX_LINE_GL_DIST_ALL dist

    gl_code_combinations_kfv gcc

    AR_RECEIVABLE_APPLICATIONS_all app

    ra_customer_trx_all a2

    ra_customer_trx_lines_all b2

    RA_CUST_TRX_TYPES_all t

    fnd_flex_values_vl flexv

    pn_lease_details_all pal

    where

    App. APPLICATION_TYPE = "CM".

    and flexv.flex_value = gcc.segment3

    and flexv. FLEX_VALUE_SET_ID = 1014916

    and pal.lease_id = d.lease_id

    and app.applied_customer_trx_id = a.customer_trx_id

    and app.customer_trx_id = a2.customer_trx_id

    and a2.cust_trx_type_id = t.cust_trx_type_id (+)

    and a2.org_id = t.org_id (+)

    and b.customer_trx_line_id = b2.previous_customer_trx_line_id

    and dist. CUSTOMER_TRX_LINE_ID = b2. CUSTOMER_TRX_LINE_ID

    and dist.account_class = 'REV '.

    and dist.account_set_flag = DECODE (NVL(a2.invoicing_rule_id,1)-2, 'Y', 'n')

    and gcc. CODE_COMBINATION_ID (+) is Dist. CODE_COMBINATION_ID

    and b.interface_line_attribute10 = d.lease_num

    and d.lease_id = e.lease_id

    and e.primary_flag = 'Y '.

    and b2.customer_trx_id = a2.customer_trx_id

    and a2.bill_to_customer_id = l.cust_account_id

    and l.party_id = m.party_id

    and a2.created_by = h.user_id

    and ps.customer_trx_id = app.customer_trx_id

    and ps.gl_date between trunc (trunc (TO_DATE (SYS_CONTEXT ('DISCO_CONTEXT', 'Date_From')), 'MM')-1, 'MM') and trunc (TO_DATE (SYS_CONTEXT ('DISCO_CONTEXT', 'Date_To')), 'MM')-1

    What exactly is the problem with the results? Can you do the report include the gl_date, so that you can see exactly what is included?

    The only way to solve this is back to basics. You must be certain that the setting and calculations for the date work 100%. You have granted the Execute permission on the function to your landlord EUL - Yes? I did create the function in a package belonged to EUL_US, then I got no problem with permissions or grant.

    Also, gl_date is a DATE string and not a right? I ask because if it is not a date, but a string then a few dates could be left out.

    Assuming that you are 100% some of the building blocks, you should start by including only the gl_date and the primary key of the table you are using. Once you are sure you have found the right data, you can start adding in addition to fields.

    I note that you use the E-Business Suite objects. I copied the code in my system where I don't use rental. So I put comment references to tables 3 PN. I had 150 lines of data when I asked for it by using the parameter, and then when I hard coded the BETWEEN operator for the gl_date. You don't have to make sure that your landlord EUL got right SELECT all tables and views used in your code and, if you want to share this code with someone else, you must also have LICENSING rights.

    Try your code in a SQL like TOAD tool and see what happens. Are you absolutely sure that each of your transactions has an entry in the tables PN? Maybe it's why you don't get the results you expect. You can try, as I did, to comment these lines out and then see what happens.

    Hopefully this has given you enough to solve your problem

    Michael

    PS. It would be nice to know your name. You have not used once it in your thread.

Maybe you are looking for

  • Analog signal DAQ drain

    We currently have a 9205 analog input module. I have several analog inputs (CSR) receive signals output of material. Recently, I discovered that if a piece of equipment is taken offline, creating an undefined signal for the data acquisition module, o

  • I can't change the read only files on my NAS unit.

    I have a promise SmartStore MS4300n Network Attached Storage system that I have used for more than two years. I can access it from my Windows Xp and my 64 bit Windows 7 computer. Yesterday, I tried to move some files from my Win 7 to the NAS and I fi

  • New printer driver is missing or Invisible - Mac

    I just downloaded and installed the drivers for a MX922.  Mac OS 10.11.3 the installer says installation was successful. The scanner drivers are all visible, but this isn't the app/printer driver.  The manual says I should be able to find and open th

  • multimedia card reader an error has occurred please drive reconnect to try again

    I have windows xp 32 bits SP3. I tried to copy the computer on a CD - RW disc images and a message kept popping up on the office. Multimedia card reader. An error has occurred please reconnect reader to try again. I got my coppied photos on the disk,

  • hard drive corrupted after the failure of the connection?

    I have the problem that the usb device is not recognized, sometimes my devices are recognized s, sometimes not, but don't I have, I have connected my external hardrive, it was not recognized, I turned it off and on again, I thought that if I restart