help with empty values

Hi all
I have a table of rates such as:
create table myRates (
rate_id number, 
rate_type number, 
param_1 number, 
param_2 number, 
rate_cost number);
Data in this table as:
insert into myRates(1, 1, null, null, 10);
insert into myRates(2, 1, 1, 1, 15);
insert into myRates(3, 1, 1, 2, 20);
insert into myRates(4, 1, 2, 1, 25);
insert into myRates(5, 1, 2, 2, 30);
insert into myRates(6, 1, null, 3, 40);
insert into myRates(7, 1, 3, null, 50);
Now I have a function to get the rate_cost
create or replace function get_cost_rate(v_type in number, v_param1 in number, v_param2 in number) return number is
  Result number :=0;
begin
   begin
   select rate_cost into Result
   from myRates 
   where rate_type = v_type
   and param_1 = v_param1
   and param_2 = v_param2;
   
   exception when no_data_found then
      select rate_cost into Result
      from myRates 
      where  rate_type = v_type
      and param_1 is null
      and param_2 is null
   end;
   return(Result);
end get_cost_rate;
How can I get the default (null) when it does not find param1 and param2?
select get_cost_rate(1,6,7) from dual; -- Result 10
select get_cost_rate(1,6,3) from dual; -- Result 40
select get_cost_rate(1,3,7) from dual; -- Result 50
Thank you

Oracle 9.1
Published by: user9542267 on February 27, 2013 12:49

Published by: user9542267 on February 27, 2013 12:52

Published by: user9542267 on February 27, 2013 13:05
select rate_cost into Result
   from myRates
   where rate_type = v_type
   and (param_1 = v_param1 OR (param_1 IS NULL AND v_param1 IS NULL))
   and (param_2 = v_param2 OR (param_2 IS NULL AND v_param2 IS NULL));

or (a bit shorter)

select rate_cost into Result
   from myRates
   where rate_type = v_type
   and (param_1 = v_param1 OR NVL(param_1,v_param1) IS NULL)
   and (param_2 = v_param2 OR NVL(param_2,v_param2) IS NULL);

or, if you know a value that is not a valid value for the params in the table (-1 maybe?)

select rate_cost into Result
   from myRates
   where rate_type = v_type
   and NVL(param_1,-1) = NVL(v_param1,-1)
   and NVL(param_2 ,-1) = NVL(v_param2,-1);

Tine

Published by: Christine Schnittker on 27.02.2013 19:27

Tags: Database

Similar Questions

  • Update a record of ORM, but with empty value

    Hi all, excuse my poor English and my level of coldfusion poor

    I have some problems to update the data with ORM objects.

    (1) I have an object of customer with a task property (many-to-one relationships)
    (2) I have a job object (a list of works)

    When I update a client with customerOBJ.setjob (jobOBJ); It is ok

    But when I can't seem to restore an empty value for the job.

    When I try this:

    customerOBJ.setJob (), I have an error because the settings is not a type of employment

    You have some information about this?

    Thanks in advance.

    Hi friend

    This allows to obtain a value zero: javacast("null",'"")

    That is why to delete the value:

    customerOBJ.setJob (javacast("null",""));

    That should make you well. If you use it in a few places, you can create yourself a function:

    Then use:

    customerOBJ.setJob (null);

  • new and need help with the value $ in a sale

    I have just come across this product and h

    Ave fall in love with. question: how to format

    from field pays $ 0.00 in

    the number field instead of only 18

    all free used is appreciated

    Define the display pattern for the numeric field to num {($z9.99)} to display as $18.00 18...

    Thank you

    Srini

  • How to remove empty entries in a table and replace them with the values of the instance?

    I have a table with values and spaces elements. I want to organize items such as table contains only values eliminating the empty spaces and re-organize the table with the values of cotimuous.  I use a bollean table to populate the items, so the bolleans to false fill the empty I don't want spaces. How can I program the above operation?

    Thank you

    Thank you for your solution, but I just found an easier way. INDEXING CONDITIONAL!. How I miss that. in any case, thanks...

  • SSRS 2012 export to CSV with no data by generating coma separated with an empty value

    I have a report that have no data due to parameter motor (both have true noheader configuration).

    In SSRS 2005 its generate empty csv file and for SSRS 2012 his record still generate with coma and an empty value, something like this:

    ,,,,

    Those that were generated by Server (SSRS 2005 and 2012 SSRS), tnot different heres in the rsreportserver.config file to make segment.

    If I exported the csv file to SQL Server Data Tools for Visual Studio 2012, it generated an empty file (which is correct).

    Anything I missed here?

    Just realized, its due to my 2012 SSRS is the RTM version and its due to SSRS bugs has been fixed on SP2 + CU3

    https://support.Microsoft.com/en-us/KB/3002049

  • Is there a default value for the color management in PSE10? Beautiful photos from iPhoto, but blur with elements. I need help with this before as I consider that the upgrade to PSE13 and beyond.

    Is there a default value for the color management in PSE10? Beautiful photos from iPhoto, but blur with elements. I need help with this before as I consider that the upgrade to PSE13 and beyond.

    Printing which forms an angle seems ok, but one that is horizontally seems faded, incomplete.

    I was wondering if I saved a layer somewhere and set it as a default value.

    If you group the layers, you will be left with a single layer, thus spreading your concern.

    Suggest that you do the following:

    1. Make sure you have the latest drivers for your printers
    2. Reset the default preferences.

    Hold the Alt, Ctrl + Shift keys when you click the icon to open the items. When asked if you want to delete the settings file, say Yes.

    Items nearby and let regenerate the file.

  • How to display the line empty as a line with null values

    Hi all

    Pls advise me if it is possible to use a single query statement to display
    Empty row (i.e. not a single return line) as a line with null values.

    For example,.

    Select the names of names_mst whose name = "sgasfgs".

    Result:
    Names of
    =====
    < null >

    Hello
    If you desire to join external to double, as shown below, you still get at least a line of production

    SELECT  nm.names
    FROM            dual
    LEFT OUTER JOIN names_mst   nm  ON nm.name='sgasfgs';
    
  • Replace the empty column with ZERO values

    Hi experts,

    I'm building a report to display the number of orders per channel / day / hour.

    Since a few days one or several channels may not all orders placed against them in which case my report shows empty values in the report.

    Ideally, I would have zero in these columns rather than an empty cell.

    Sample Qry: -.

    Select
    Channel,
    Count (order_num) County
    Of
    SALES_ORDER

    Pls help!


    Thanks in advance.

    Count always returns 0 if no line found or the actual number based on the found rows. You don't even have to NVL them. I think so
    the problem is in your report layout, in my opinion.

    You run query sqlplus, or Toad or sqldevloper and you can see for yourself that the count is 0.

    See you soon.
    VIN.

  • Need help with the property setting.

    Hi all

    I need a help in a drift a property setting.

    We have a HP planning property definition in DRM. Sourceplan which is a defined property type with a default value as plan1.

    I want to make this value of a derived property and add a parameter here inorder to fulfill my obligation i, e

    If a hierarchy is to have a node name containing the string value ABC, XYZ or MNC then it HP. Type of SourcePlan must get filled with value Plan, Plan2 and plane3, otherwise it must be an empty value.

    I need a help on the settings here.

    Thank you

    Madhu

    Try this malfoy-

    If)

    LessThan (Length (ReplaceStr (Abbrev (), ABC, F)), Length (Abbrev (()), Integer).

    Base1,

    If)

    LessThan (Length (ReplaceStr (Abbrev (), XYZ, F)), Length (Abbrev (()), Integer).

    Plan2,

    If)

    LessThan (Length (ReplaceStr (Abbrev (), MNC, F)), Length (Abbrev (()), Integer).

    Plane3)

    )

    )

    Thank you

    Denzz

  • Help with conditional display and Validation

    Version 4.1.1.00.23

    Hello

    I'm having a difficult time with a conditional display and validation, I hope someone can help with.

    Requirements:

    When (Datepicker) Start Date or the end Date (Datepicker) change can display the reason for change (select list) and change Description (Textbox)
    If the page is saved without entering a reason change display an error message of validation that the reason for the change cannot be empty (NULL)

    What I tried

    Create a dynamic Action on the Start Date

    Event: Change

    Selection type: Article (s)

    Items (s): P51_START_DATE

    Condition: no

    Real Action Section:

    Action: Show

    Fire on Page load: Checked

    Display all the elements of the page on the same line: NO.

    Section of the elements concerned:

    Selection type: Article (s)

    Product (s): P51_CHANGE_REASON, P51_CHANGE_DESC

    I also created a dynamic Action with similar settings for the P51_END_DATE.

    I created a Validation for the P51_CHANGE_REASON as a function return error text:

    DECLARE
        v_start_date    work_items.start_date%TYPE;
        v_end_date      work_items.end_date%TYPE;
    BEGIN
        SELECT start_date
              ,end_date
        INTO   v_start_date
              ,v_end_date
        FROM   work_items
        WHERE  work_items_id = :P51_WORK_ITEMS_ID;
        IF ( (v_start_date != TO_DATE(:P51_START_DATE,'DD-MON-YYYY') OR v_end_date != TO_DATE(:P51_END_DATE,'DD-MON-YYYY') ) AND
              :P51_CHANGE_REASON IS NULL ) THEN
            RETURN 'Change Reason must have a value';
        END IF;
    END;
    
    
    

    The question

    I tried to create another dynamic Action to hide the P51_CHANGE_REASON and P51_CHANGE_DESC fields during the loading of the page, but when the date fields are changed and the validation is fired the P51_CHANGE_REASON and the P51_CHANGE_DESC are hidden again.

    There are two buttons to send the page: 'SAVE' will submit the page and stay on the page and 'SAVE_CHANGES' will present the page and creates a branch to the previous page (which is a relationship with the EDIT buttons to change recording).

    I can not loading the dynamic Action page for fires DO NOT when validation is triggered.

    I hope it is clear and if not what information can I provide?

    Thank you

    Joe

    Which the condition is failing and what browser? I tested it in Firefox and it works as it should. Can you confirm that?

  • Advanced search for a price range while searching for an empty values using php in DW

    I'm creating an advanced search with DW php. I want to present a research where some titles can be left black. If looking for empty values (which I did, thank you David Powel), however then research across a range of prices doesn't seem to work.

    Please see attached form:

    The search page:

    <form action="Detailed-Search-Result.php" method="get" target="_self"><table width="90%" border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td colspan="2"><label for="Detailed Search">Advanced Search</label></td>
        </tr><tr>
        <td><label for="Product">Product:</label>
          </td>
        <td><select name="Category" id="Category">
          <option value=></option>
            <option value="Keyboard">Keyboard</option>
            <option value="Piano">Piano</option>
          </select></td>
      </tr>
      <tr>
        <td><label for="Make">Make:</label>
        </td>
        <td><select name="Manufacturer">
          <option value=></option>
          <option value="Boss">Boss</option>
          <option value="Casio">Casio</option>
          <option value="Kawai">Kawai</option>
          <option value="Ketron">Ketron</option>
          <option value="Korg">Korg</option>
          <option value="Roland">Roland</option>
          <option value="Samson">Samson</option>
          <option value="Yamaha">Yamaha</option>
        </select></td>
      </tr>
      <tr>
        <td><label for="Color">Color:</label></td>
        <td><select name="Color">
          <option value=></option>
          <option value="Black">Black</option>
          <option value="Cherry">Cherry</option>
          <option value="Mahogany">Mahogany</option>
          <option value="Polished Eboney">Polished Eboney</option>
          <option value="Rosewood">Rosewood</option>
          <option value="White">White</option>
          <option value="Red">Red</option>
        </select></td>
      </tr>
    
      <tr>
        <td><label for="Price">Price:</label></td>
        <td><select name="Price">
          <option value=></option>
          <option value="0-500">£0-500</option>
          <option value="500-1000">£500-1000</option>
          <option value="1000-2000">£1000-2000</option>
          <option value="2000">£2000&gt;</option>
        </select></td>
      </tr>
      <tr>
        <td colspan="2">
          <input name="Search2" type="submit" id="Search2"></td>
        </tr>
        </table>
    </form>
    
    

    The results page

    $varCategory_rsgetsearch2 = "%";
    if (isset($_GET['Category'])) {
      $varCategory_rsgetsearch2 = $_GET['Category'];
    }
    $varMake_rsgetsearch2 = "%";
    if (isset($_GET['Manufacturer'])) {
      $varMake_rsgetsearch2 = $_GET['Manufacturer'];
    }
    $varColor_rsgetsearch2 = "%";
    if (isset($_GET['Color'])) {
      $varColor_rsgetsearch2 = $_GET['Color'];
    }
    $varPrice_rsgetsearch2 = "%";
    if (isset($_GET['Price'])) {
      $varPrice_rsgetsearch2 = $_GET['Price'];
    }
    mysql_select_db($database_dBconn, $dBconn);
    $query_rsgetsearch2 = 'SELECT * FROM products';
    $where = false;
    if (isset($_GET['Category']) && !empty($_GET['Category'])) {
     $query_rsgetsearch2 .= ' WHERE Category LIKE varCategory '. GetSQLValueString($_GET['Category'], 'text');
      $where = true;
    }
    if (isset($_GET['Manufacturer']) && !empty($_GET['Manufacturer'])) {
      if ($where) {
       $query_rsgetsearch2 .= ' AND ';
      } else {
       $query_rsgetsearch2 .= ' WHERE ';
        $where = true;
      }
     $query_rsgetsearch2 .= 'Manufacturer LIKE varManufacturer ' . GetSQLValueString($_GET['Manufacturer'], 'text');
    }
    if (isset($_GET['Color']) && !empty($_GET['Color'])) {
        if ($where) {
       $query_rsgetsearch2 .= ' AND ';
      } else {
       $query_rsgetsearch2 .= ' WHERE ';
        $where = true;
      }
      $query_rsgetsearch2 .= 'Color LIKE varColor ' . GetSQLValueString($_GET['Color'], 'text');
    }
    if (isset($_GET['Price']) && !empty($_GET['Price'])) {
        if ($where) {
                        } 
       $query_rsgetsearch2 .= ' AND ';
      } else {
       $query_rsgetsearch2 .= ' WHERE ';
        $where = true;
      }
     switch( $_GET['Price'] ){
            case '0-500':
            $query_rsgetsearch2 .= '  RRP BETWEEN 0 AND 500 ORDER BY price ASC'. GetSQLValueString($_GET['Price'], 'text');
            break;
              case '500-1000':
            $query_rsgetsearch2 .= ' RRP BETWEEN 500 AND 1000 ORDER BY price ASC'. GetSQLValueString($_GET['Price'], 'text');
            break;
                        case '1000-2000':
            $query_rsgetsearch2 .= ' RRP BETWEEN 1000 AND 2000 ORDER BY price ASC'. GetSQLValueString($_GET['Price'], 'text');
            break; 
              case '2000':
           $query_rsgetsearch2 .= ' RRP BETWEEN 2000 AND 10000 ORDER BY price ASC'. GetSQLValueString($_GET['Price'], 'text');
            break;
    }
    
    $query_rsgetsearch2 = sprintf("SELECT * FROM products WHERE Category LIKE %s AND products.Manufacturer LIKE %s AND products.Color LIKE %s", GetSQLValueString("%" . $varCategory_rsgetsearch2 . "%", "text"),GetSQLValueString("%" . $varMake_rsgetsearch2 . "%", "text"),GetSQLValueString("%" . $varColor_rsgetsearch2 . "%", "text"));
    $query_limit_rsgetsearch2 = sprintf("%s LIMIT %d, %d", $query_rsgetsearch2, $startRow_rsgetsearch2, $maxRows_rsgetsearch2);
    $rsgetsearch2 = mysql_query($query_limit_rsgetsearch2, $dBconn) or die(mysql_error());
    $row_rsgetsearch2 = mysql_fetch_assoc($rsgetsearch2);
    
    

    I would be greatfull for any help

    I managed to solve the problem.

    Ultimately I don't check if the values were empty, as it worked fine without. However, the switch of the price did not work in combination with the rest of the query.

    I solved the problem as follows:

    $varCategory_rsgetsearch2 = "%";
    if (isset($_GET['Category'])) {
      $varCategory_rsgetsearch2 = $_GET['Category'];
    }
    $varMake_rsgetsearch2 = "%";
    if (isset($_GET['Manufacturer'])) {
      $varMake_rsgetsearch2 = $_GET['Manufacturer'];
    }
    $varColor_rsgetsearch2 = "%";
    if (isset($_GET['Color'])) {
      $varColor_rsgetsearch2 = $_GET['Color'];
    }
    $varPrice_rsgetsearch2 = "%";
    if (isset($_GET['Keysound_price'])) {
      $varPrice_rsgetsearch2 = $_GET['price'];
    
    }
    mysql_select_db($database_dBconn, $dBconn);
    $query_rsgetsearch2 = sprintf("SELECT * FROM products WHERE Category LIKE %s AND products.Manufacturer LIKE %s AND products.Color LIKE %s", GetSQLValueString("%" . $varCategory_rsgetsearch2 . "%", "text"),GetSQLValueString("%" . $varMake_rsgetsearch2 . "%", "text"),GetSQLValueString("%" . $varColor_rsgetsearch2 . "%", "text") );
    switch( $_GET['price'] ){
            case '0-500':
            $query_rsgetsearch2 .= ' AND price BETWEEN 0 AND 500 ORDER BY price ASC';
            break;
              case '500-1000':
            $query_rsgetsearch2 .= ' AND price BETWEEN 500 AND 1000 ORDER BYprice ASC';
            break;
                        case '1000-2000':
            $query_rsgetsearch2 .= ' AND price BETWEEN 1000 AND 2000 ORDER BY price ASC';
            break;
              case '2000':
            $query_rsgetsearch2 .= ' AND price BETWEEN 2000 AND 10000 ORDER BY price ASC';
            break;
    }
    
    $query_limit_rsgetsearch2 = sprintf("%s LIMIT %d, %d", $query_rsgetsearch2, $startRow_rsgetsearch2, $maxRows_rsgetsearch2);
    $rsgetsearch2 = mysql_query($query_limit_rsgetsearch2, $dBconn) or die(mysql_error());
    $row_rsgetsearch2 = mysql_fetch_assoc($rsgetsearch2);
    

    I'm sure you can keep checking the values, however for me the most was not necessary for this.

    Thanks for your help

  • VO with static values

    I WANT TO CREATE A MESSAGE OF CHOICE WITH STATIC VALUES. FOR THIS I HAVE CREAT VO
    Name: DeviseVO
    attributes: RowKey (primaryKey, number)
    Values (String)

    I creat the initialiserDevise() method and call it from the PR

    Public Sub initialiserDevise()
    {
    String [] values = {'Dinar', 'Euro', 'Dollar'};
    DeviseVOImpl pervo = getDeviseVO1 ();
    If (Pervo.getFetchedRowCount () == 0)
    {
    for (int i = 0; i < 3; i ++)
    {
    pervo.executeQuery ();
    Bow of row = pervo.createRow ();
    pervo.insertRow (prow);
    Try
    {
    prow.setAttribute ("RowKey", new Number (i));
    prow.setAttribute ("values" [i]);
    pervo.getCurrentRow () .validate ();
    }
    catch (Exception ex)
    {
    pervo.getCurrentRow () .remove ();
    }
    }
    }
    pervo.executeQuery ();
    System.out.println (Pervo.getFetchedRowCount ());
    }

    My problem that the list is as empty and the display method 0

    Help please

    Thank you

    Hello

    This requirement is quite simple that instead of writing code you can write query in English like this

    Select "Dinar" dual union select 'Euro' from dual union select 'Dollar' of the double

    and after that, you need not to run the query on this OAF do by itself, even then I suggest you to create a list of choices for this and then later you want to add the value or delete what can be done without changing the code.

    Hope this will help :)

    Kind regards
    Out Sharma

  • Filter a column with the value of another

    Hello. Hope someone can help with this... On my search page, I want to use the value of the first list/drop-down menu to filter the values of the second list/menu. I use PHP and DW 8.0.2.

    Example: The first column has each of the 50 States. second column has 3 000 counties. If a user selects New Jersey, I want to just 21 NJ counties to appear as options in the second menu downwards rather than 3 000 counties.

    First Recordset works very well for the States. But in my second recordset, I say 'select distinct County of the said County WHERE AS var1'... and var1 is $recordset1 [County]. But the 2 column is empty. How can I actively pass the value of the first column in the second while the user is still on the same page?

    Sandman

    >>
    Assuming that your table has a field named "State":
    «select County of States WHERE state = "var1""
    >>

    You can use this solution when the first menu page 1 and the second menu on page 2 (IE passing the value of a query on page 2), but as assumingly, you need to have this functionality within a single page, basic need based on a javascript solution 'drop-down menus of dynamic load' to load the menu2 - options "in situs.

    There is an extension for Dreamweaver stand alone for this on the site of Tecnorama , that also wants to work without the relationships between the tables, in other words, with the data in a table, which matches your scenario.

  • List/Menu, TextField &amp; amp; TextArea with initial values

    I have an html form that uses the intrusion via cfmail to send data to my email. On the form, there is some initial values I want to display empty if the values are the same as the initial values. How can I do this (or is it possible)?

    Example 1: List/Menu (initially selected):
    If the originally selected value = "Please indicate 1 2 3 Maj" then leave blank. Otherwise show some other value of the option that was selected.

    Form.htm
    < select name = "046 a" id = 046 'a' >
    < option value = "Please indicate 1 2 3 Maj" selected = "selected" > please indicate 1-2-3 SHIFT < / option > "
    < option value = "1st shift" > 1st shift < / option >
    < option value = "2nd quarter" > 2nd quarter < / option >
    < option value = "3rd quarter" > 3rd quarter < / option >
    < / select >

    CFMAIL.cfm
    #Form.046a # full time

    Example 2: TextField with the initial value:
    If the originally selected value = 'Please spΘcifier' then leave blank. It does not show any new text that was entered.

    Form.htm
    < input name = "003" type = "text" id = "003" onfocus = "this.value ="; "" " This.onfocus = null; ' value = 'Please spΘcifier' size = '35' / >

    CFMAIL.cfm
    Others. ...: #Form.003 #.

    Example 3: TextArea with initial value:
    If the originally selected value = "Work" then leave blank. It does not show any new text that was entered.

    Form.htm
    < name textarea = "107" cols = "44" lines "5" = class = "textHideScroll" id = "107" onfocus = "this.value ="; "" " This.onfocus = null; "> work < / textarea >

    CFMAIL.cfm
    Work carried out. ...: #Form.107 #.

    Thank you

    Jeff

    Quote:
    Posted by: emmim44
    You store data in db or not? If this isn't the case, every time when you submit the form it will be more to write the old value of form fields... You can store the value in a session variable and compare with the new value of form field... Hope it helps...

    Thanks, but I already had my question answered when I posted the following message title:
    «Question text box»

    I will mark this as the answer to prevent others to respond.

    Thanks again,

    Jeff

  • Data for an empty value in a report formatting

    Hello world


    I've created a report of a region with four measure. In this report, I have no data for some areas. But still I want to display "Zero" instead of the empty value.


    Please any one help me for that matter.

    Scenario is:

    A B C D

    US 12 23 0
    UK 34 56 in white
    White Asian 67 67



    Concerning
    REDA

    Jin
    With the HELP of Filter (IFNULL(MEASURE_NAME,0) cal_month between ' 2009 - 04 - 01 00:00:00.000' and ' 00:00:00.000' 2009-12-01)

    If you found this useful award of points

    Thank you
    Angelique

Maybe you are looking for

  • How to use Zotero on Firefox for Android?

    Download Zotero for Firefox on my tablet as I do on my PC?

  • Satellite P100-203: need cable S/PDIF

    My laptop (Satellite P100-203) supports a line output (3.5 mm) with features for the S/PDIF digital output. I would like to connect my laptop to my HiFi, but it seems to be difficult to find a cable supporting this connection and S/PDIF. Does anyone

  • Information scaling of data acquisition

    I have a DAQ hardware that measures 0-10 volts of input. We measure a signal that goes from 0-15 volts, so we atenuating the signal by a factor of 2.  MAX I created a scale with a slope of 2 who should be able to display the 0-15 Volt input voltages,

  • HP ENVY 15 t-j100 Select Edition CTO Notebook PC Network Drivers

    Hi, I hope someone can help with this problem. I just bought my new laptop and did a downgrade to Windows 7 Ultimate 64-bit.  I have almost everything now except for Bluetooth.  My portable computer product number is E9W31AV It comes with bluetooth a

  • WRT160N crashes

    I looked in all the forums, but I can't seem to find any help. I have reflashed the firmware several times, reset the settings by default, etc., but the router crashes. I have a mixed environment (G & N) boxes 3 windows and a Mac. I just a bad router