CERTAIN behaviors, NULL values

I am a little confused about the following situation:

I have a PL/SQL code with a block similar to this:

BEGIN
SELECT MAX (col1)
IN myVar
FROM MyTable
WHERE col1 < (SELECT MAX (col1) FROM MaTable;

EXCEPTION
WHEN NO_DATA_FOUND THEN
myVar: < something > =;
WHEN OTHERS RAISE.
END;

The behavior I expect from this is to assign a value to myVar, which is the next most great. value to the record value of col1.  If there is no record in myTable the NO_DATA_FOUND exception is thrown and myVar is filled with predetermined values.  Everything works fine execpt...

When there is only one record stored in myTable, there is no exception raised and myVar is assigned to NULL.  I think that since there is only one line in the table there is no trace of return that meets the SELECTION criteria and therefore the NO_DATA_FOUND exception which is not the case here would be raised but myVar is assigned NULL and the program continues to flow from there.

What is the problem with my way of thinking that the exception must be raised when there is a single record in myTable?

Thank you.

Documentation:

A SELECT INTO statement returns no rows, or your program refers to an element deleted in a nested table or a component not initialized in an index - by table. Aggregate SQL such as AVG and SUM always functions return a value or a null value. As a result, a SELECT INTO statement that calls an aggregate function ever triggers NO_DATA_FOUND.

That would be your MAX.

Tags: Database

Similar Questions

  • Bar chart stacked - strange behavior on display null values

    Hi all

    I'm trying to graph a county of the end dates of the activities over several years by months grouped by project.

    The problem I have is that there is a gap of 3 months where none of the activities that I am tracking complete. The default value for the stacked bar chart is to ignore the columns with no data (in my case it October-December 2015).

    To view these any given month I went to properties graphic and ticked the box "Include Null values. At this point, I get a very strange behavior. Once this option is selected, the legend explodes, showing each project in the database regardless if it meets my criteria for analysis.

    Has anyone another considering that happen? I'm doing something wrong?

    If it's important I'm in the OBI 11.1.1.7.150120

    Thank you for your help,

    Kevin Wolfe


    Hello

    You have a filter on the list of projects you want to see?

    Based on the way you describe your analysis I guess you don't have any what filter on the list of projects, but some of the filters on the other dimensions/attributes and these filters were limiting the list of projects.

    If this is the case then what you see is not a weird behavior, but everything you've asked your analysis.

    "Include null values" is not limited to the time dimension, it fits any dimension of your analysis, so no filter on projects = all projects.

  • apex5, a null value to the title of the tree made the developer toolbar disappear

    Hello

    With for example the query tree:

    select case when connect_by_isleaf = 1 then 0
                when level = 1             then 1
                else                           -1
           end as status, 
           level, 
           (CASE WHEN "ENAME" = 'KING' THEN null ELSE "ENAME" END) as title, -- null value is evil
           null as icon, 
           "EMPNO" as value, 
           null as tooltip, 
           null as link 
    from "#OWNER#"."EMP"
    start with "MGR" is null
    connect by prior "EMPNO" = "MGR"
    order siblings by "ENAME"
    

    The developer toolbar disappears when there is a value zero in the title. It's very very difficult to detect the problem.

    https://Apex.Oracle.com

    workspace: imagetest_ws

    user: guru

    Pass: meditation

    App: imgtst

    page: 12

    Rgrds Paavo

    Hi Paavo,

    Can I ask what you are trying to achieve by one of the labels by assigning null value?

    Null or an empty string are not useful as a tree node labels. Yet we could be as a minor bug that the area of the tree should be more robust in the JavaScript that it generates.

    Detect the problem (disappears from the dev toolbar) is not different from almost all JavaScript errors. Whenever any client-side behavior seems to not work, for example, no dev toolbar or a tree node does not expand, or a menu is not falling down, or something is not show or hide it should etc, the first thing to check is the browser console log. In this case, it shows the error ' SyntaxError: lack the name of the variable.

    Kind regards

    -John

  • Make a selectOnechoice of null value.

    Hello

    I use Jdev 11.1.2.4

    I have two selectOneChoice soc1 and soc2 in the columns of the table. I want to make the soc2 null value based on a certain value of soc1. How to get the value of selectOneChoice to null?

    I tried to use the code below... but it does not work.

    < af:column sortProperty = "#{bindings." DownVO1.hints.ProductId.name}.

    sortable = "false".

    headerText = "#{bindings." DownVO1.hints.ProductId.label}"id ="c9">

    < af:selectOneChoice value = "If #{row.bindings.ReasonId}!" = 1

    #{row.bindings.ProductId.inputValue}

    on the other

    null; »

    label = "#{row." Bindings.ProductID.label}.

    required = "#{bindings." DownVO1.hints.ProductId.mandatory}.

    shortDesc = "#{bindings." DownVO1.hints.ProductId.tooltip}.

    ID = 'soc2' disabled = ' #{rank. " CatId == 1? {false: true} ">"

    < f: selectItems value = "#{row.bindings.ProductId.items}" id = "si2" / > "

    < / af:selectOneChoice >

    < / af:column >

    Thank you

    Hello

    try to follow this:

    1 let the value of soc2 because it is as

    2 - Open the viewobject--> java---> Java Classes--> generate view class (the class will be like ViewnameViewRowImpl).

    3 - Open class ViewnameViewRowImpl and in the accessor soc1 Set set soc2 with null:

      public void setReasonId(String value)
      {
        setAttributeInternal(REASONID, value);
         if(value != null && value.equals("1")
         {
              setProductId(null);
         }
      }
    

    3. in the .jspx soc1 set set autoSubmit = 'true '.

    
    

    4. in the .jspx soc2 set partialTriggers = 'soc1.

    
    
  • Properties: Treatment of NULL values

    I wanted to ask you how you deal with NULL values, on the properties of JavaFX.

    Properties of the wrapper for the primitive data types like SimpleIntegerProperty or SimpleBooleanProperty Don t accepts NULL values.

    Example:

    1. IntegerProperty integerProperty = new SimpleIntegerProperty() )
    2. integerProperty. setValue (null) ;
    3. System. out. println () integerProperty. getValue ());

    Output is 0 (default value for "int").

    I think the primitive property wrappers (IntegerProperty, BooleanProperty and friends) as of the wrappers for primitive types. Probably they shouldn't really inherit WritableValue as which allows the call to setValue with a type reference, but I think that indigestion API would be worse than the implementation of setValue with a slightly incorrect signature. I would just avoid defining a wrapper of primitive type to null property: If you want to restrict yourself using set (.) instead of setValue (...) you are forced to spend in the primitive type: either you cannot pass null.

    If you want an integer property where null values are handled in an intuitive manner, use ObjectProperty .

    The test below shows that call setValue (null) on IntegerProperty assigns the default value. (Although I don't see the behavior documented anywhere).

    import javafx.beans.property.IntegerProperty;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleIntegerProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    
    public class PrimitivePropertyWrapperTest {
    
        public static void main(String[] args) {
            IntegerProperty integerProp = new SimpleIntegerProperty();
            integerProp.addListener(new ChangeListener() {
    
                @Override
                public void changed(ObservableValue observable,
                        Number oldValue, Number newValue) {
                    System.out.println("integerProperty changed value from "+oldValue+" to "+newValue);
                }
            });
    
            ObjectProperty objectProp = new SimpleObjectProperty<>();
            objectProp.addListener(new ChangeListener() {
    
                @Override
                public void changed(ObservableValue observable,
                        Integer oldValue, Integer newValue) {
                    System.out.println("objectProperty changed value from "+oldValue+" to "+newValue);
                }
            });
    
            integerProp.setValue(null);
            integerProp.setValue(1);
            System.out.println("setting integerProp back to null:");
            integerProp.setValue(null);
            System.out.println("setting integerProp to 0:");
            integerProp.setValue(0);
            integerProp.setValue(null);
    
            objectProp.setValue(null);
            objectProp.setValue(1);
            objectProp.setValue(null);
            objectProp.setValue(0);
            objectProp.setValue(null);
    
        }
    
    }
    
  • Returns the null value in HasMap.get ().

    Hi all.
    Just read the docs of java on hashmap and was interested in this topic the get() method:

    A NULL return value does not necessarily mean that the map contains no mapping for the key; It is also possible that the map explicitly maps the key null. The containsKey operation may be used to distinguish these two cases.

    I took in a case, which has been talked about: If the map allow nulls, returned by get() null will be just one key of the pair-> null value. But the second case is not clear to me. Please, show me an example for the latter case, when get() can returned null.

    sphinks wrote:
    I took in a case, which has been talked about: If the map permits null values, returned by get() null will be just a key pair-> null value. But the second case is not clear to me. Please, show me an example for the latter case, when get() can returned null.

    There is no second case. There is a single case, if you put a null value in a map, get() will return null. And because of that, if you need to know if a certain key is in the containsKey() worksheet should be used instead of the get() method.

  • Replace NULL values for PIVOT query

    Hello

    I'm working a table for sales, for certain values, when now columns, finishing with a null value. How can I handle these values 0 (zeros).

    WITH (AS PIVOT_DATA)
    SELECT S.ZONE_CODE, Z.ZONE_NAME, S.YEAR, S.PERIOD, S.SALES
    OF STAT_TABLE_SALES ADV
    AREAS OF JOIN Z ON S.COMP = Z.COMP AND S.ZONE_CODE = Z.ZONE_CODE
    WHERE S.COMP = '001'
    AND S.BRAND_CODE = '001'
    )
    SELECT *.
    OF PIVOT_DATA
    PIVOT)
    SUM (SALES) FOR THE PERIOD (YEAR) TO ((20091),
    (2009,2),
    (2009,3),
    (20094)
    (2009,5),
    (2009,6),
    (2009,7),
    (2009.8),
    (2009,9),
    (2009.10)
    (2009,11),
    (2009.12),
    (2010,1),
    (20102)
    (2010,3),
    (2010,4),
    (2010,5),
    (2010,6),
    (2010.7))
    )
    ORDER BY DESC NULLS LAST 14;

    This query returns the following:

    COD_ZONA NOM_ZONA 2009_3 2009_2 2009_1
    -------- ------------------------------ ---------------------- ---------------------- --------------------
    01 YEDUSIJH. 1382367.75 1559943.27 1441279.64
    02 C, ASKAK 711897.82 865854,05 1583232.3
    ASDFG 03 130443.03 205409,84 178633.69
    04 OSOIDSD 320118.32 439008,83 409251.18
    05 ODFSDF 300908.21 276301,59 260188.53
    06 CH 242749.65 325196,71 464938.9
    SOA 07 610312.31 606312,93 754569.82
    08 SAN 89426.8 81360,04 61649.27
    09 YP 284487.79 328281,31 267210.85
    10 TC 87043.28 158594,43 85195.8
    11 BAGNN 76778.78 68180,76 118530.04
    12 CRT 122023.7 143442,21 134744.85
    13 ABC 209992.79 196477,03 185222.14
    IDLIB 14
    15 ARE 23870.41 4137,33 16660.53

    * These are not all the columns and rows, but it is a piece of what it returns.

    How can I replace the NULL values with 0 (zeros).

    Still not sure why nvl shouldn't meet your needs:

    SQL> select ename, nvl (clerk_20, 0) clerk_20, nvl (sal_30, 0) sal_30
      from emp pivot (sum (sal)
               for (job, deptno)
               in ( ('CLERK', 20) clerk_20, ('SALESMAN', 30) sal_30))
    /
    ENAME             CLERK_20          SAL_30
    ---------- --------------- ---------------
    WARD                     0            1250
    JONES                    0               0
    TURNER                   0            1500
    ADAMS                 1100               0
    ALLEN                    0            1600
    SMITH                  800               0
    CLARK                    0               0
    KING                     0               0
    BLAKE                    0               0
    JAMES                    0               0
    FORD                     0               0
    SCOTT                    0               0
    MARTIN                   0            1250
    MILLER                   0               0
    
    14 rows selected.
    
  • ORDER BY a column with NULL values only

    Hello

    The order of column has all null values for the results of my query set.

    Ex:

    Select a, b, c from table1 where type = 'type1' and ID = "id1" order by column1

    In the above query, "column1" contains nulls for 'type1 '. The order of the records in the result set is different for different ID values if the values of a, b and c are always the same.
    What is happening in the 10g database.

    I have also observed that the order of the records for the same query conforms in the 9i database.

    (1) is the difference due to the difference in versions of database?
    (2) is there a way to get the order even records independently entry ID?
    (3) I cannot in the same order in 10 g DB too as the order in 9i DB?

    Thank you.

    Hello

    Madhuri says:
    Hello

    The order of column has all null values for the results of my query set.

    Ex:

    Select a, b, c from table1 where type = 'type1' and ID = "id1" order by column1

    In the above query, "column1" contains nulls for 'type1 '. The order of the records in the result set is different for different ID values if the values of a, b and c are always the same.
    What is happening in the 10g database.

    I have also observed that the order of the records for the same query conforms in the 9i database.

    If two or more rows have the same values (or NULL) for each ORDER BY expressions, then you may not be sure what order they will be. The system is free to do whatever he finds convenient. What the system identifies Dresser can vary depending on many factors, including the version, the size of the table, the conditions in the WHERE clause, there is a GROUP BY clause, or not... In all cases, it is not something that you can depend on. If you want the output in a certain order, to specify the order in the ORDER BY clause.

    (1) is the difference due to the difference in versions of database?

    Could be. In all versions, Oracle said that you cannot count on the order being compatible, except if the ORDER BY clause, it is consistent.

    (2) is there a way to get the order even records independently entry ID?

    Add more expressions at the end of the ORDER BY clause, as tie-breakers.
    For example:

    ORDER BY  column1
    ,         a
    ,         b
    ,         c
    

    If table1 is really a table (not a view), you can add a ROWID.
    In most cases, you can ORDER BY expressions that are not in the SELECT clause. So if you have a primary key, you can usually ORDER BY it, even if you don't see it.

    (3) I cannot in the same order in 10 g DB too as the order in 9i DB?

    Of course, ORDER BY works the same in all versions. If you have an ORDER BY clause to unambiguously, the output will be exactly the same order in any version.
    Remember that the absence of ORDER BY has no effect in all versions. If you have an ORDER BY of ambiguous clause, you can not count on the coming out in a particular order in any version.

  • oci_bind_by_name and null values

    Hi, I'm developing a PHP application that allows users to execute SQL statements on an Oracle database. The idea behind the app does the administrator pass a query with some bind variables, for example:

    SELECT NAME, SALARY, DEPTNO of EMPLOYEES WHERE SALARY >: salary AND DEPTNO =: deptno

    After this, users are presented with a series of screens that allow them to select columns that they want to see (in our case they could choose between NAME, SALARY and/or DEPTNO) and enter values for the bind variables (in our case it would be salary and deptno). So far, everything works as expected.

    The problem I have is that if a value null is entered (say for example in deptno, we know the employees that are part of any Ministry), the oci_bind_by_name() function function that I use php to make the bindings of variables does not match all records. I understand that if you put something like "AND DEPTNO = NULL" the query should return no results. But, is it possible to do with oci_bind_by_name() behave similarly as if the query would have been "AND DEPTNO IS NULL" when it receives a null value?

    Modify the query using PHP is an option that I would avoid because I can't make all the assumptions on the query as it is entered by an administrator.

    Thank you for your time.

    Because this behavior is not specific to PHP OCI8 or the use of bind variables, you'll need to arrive at a SQL solution.

    Your comment about not being able to make assumptions on the motion seem strange: If the administrator wants the semantics you describe, they will need to write the SQL statement that is appropriate for their desired output.

    Other types of solutions include put (s) in a PL/SQL procedure that returns a ref cursor You can hide the complexity of PHP by linking only to the PL/SQL procedure parameters. But this seems to deviate away from your goals.

  • problem of null values

    Hello

    I have a summary form that displays data from more than 10 tables, so I wrote manual sql query for each field to extract data from the database. but I got error "no data found" if one field was not filled or be null.
    So, how can I handle this null values so that the other data will be displayed and only certain fields will be null, which has no data.

    Because only extraction of form will be no insertion will be held but I can not use "SQL" as a Source because the sequence of data extraction is different from the display sequence of fields on the user interface, so some data get never recovered.

    Thanks in advance
    Rupesh

    Rupesh,

    Try to avoid the "while OTHERS THEN". Use "WHEN NO_DATA_FOUND THEN." This will prevent you other unexpected errors of masking.

    Kind regards
    Dan

    http://danielmcghan.us
    http://www.skillbuilders.com

    You can reward this answer by marking as being useful or correct ;-)

  • You can not call a method on a null value expression.

    Hello

    We are working on the tool of basic hygiene WMI for windows 2008 server of health check of the scent system but in error during the run automation tool

    "Cannot call a method on a null expression."

    LE000561ERROR: You can not call a method on a null value expression.
    ERROR: The value of the argument cannot be an empty string.

    Please suggest the same

    Hi Diakité Srivastava,

    Your question is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the TechNet forum.

    http://social.technet.Microsoft.com/forums/en/category/WindowsServer/

  • NULL values for some elements of the XML reading tree

    I am confirming that I interpret correctly all the elements of a custom data XML structure defined by my application (the schema is completely under my control).  Some of the elements in my XML tree are read as NULL values, even if similar items are readind as expected.  I have checked some obvious things like misspelling the names of keys, but have not yet find the problem.  Anyone who has debugged similar questions - what else could cause this?

    Example XML:

    
        1.0.0.0
        1000
        MyAppsName
        
            
                1000
                userDefined
                StructName
            
        
    
    

    And extracted C++ w/comments at the end of each line about what I see (DataManager is my class of CRUD operations):

    In DataManager.hpp:

    QVariant mCustomDataStructsTopLevel;
    QVariantMap mCustomDataStructsTopLevelMap;
    

    In DataManager.cpp:

    mCustomDataStructsTopLevel = mXda.load(Utils::dataFilePath(customDataStructsFileName));  // XmlDataAccess; verified loading w/no errors
    mCustomDataStructsTopLevelMap = mCustomDataStructsTopLevel.toMap();
    
    qDebug() << "appName element value: " << mCustomDataStructsTopLevelMap["appName"]; // Outputs "MyAppsName" as expected
    qDebug() << "lastId element value: " << mCustomDataStructsTopLevelMap["lastId"]; // Outputs null (specifically: QVariant(, ) ) - this is NOT expected
    qDebug() << "appVersion element value: " << mCustomDataStructsTopLevelMap["appVersion"]; // Outputs null (specifically: QVariant(QString, "") )  - this is NOT expected
    

    OK, I got the feeling (and actually hoped) it was a silly mistake of face-palm on my part (compared to a problem of BB10 who had little chance of getting fixed).

    The problem is that I copy the structure of custom data from Starter to my Active dir to my data directory to first install but do not crush him on subsequent launches, as the copy in the data directory is what the user changes and relies on.  I was not a delete and reinstall on each of my iterations, so I wasn't really loading the modified versions of my XML I wanted--just, I was getting a day old stale version which was actually for the items I didn't expect NULL values for nulls.  DOH!

  • PersistentStore.getPersistentObject returns the null value?

    I use a random key to retrieve a shape of the object PersistentStore

    persist is PersistentStore.getPersistentObject (KEY);.

    Works fine on the Simulator (OS 5), when I take the code signed to the device (BB OS 5.0 Bold 8900)

    For some reason, it returns null, without exception. Thereafter any API I inoke on PersistentStore / persist returns null without exception persist even when the null value.

    I don't know if it's one thing to eclipse debugger, but even if the debugger shows that objects are null. Controls null applied in the code seems to fail, what does code see these objects as non-null. Pheww! How is it possible.

    In this code still shows up as null, then safetyTable and orderedkeys. However, the value null check in the failure code.

    At a later stage in the code, when I try to access orderedkeys are null again! Are struggling with this problem for two days, all the pointers would be very comfortable.

                        persist = PersistentStore.getPersistentObject( KEY );
                        persistOrderedKeys = PersistentStore.getPersistentObject(KEY_ORDERED_KEYS);
                        safetyTable = (Hashtable)persist.getContents();
                        orderedKeys = (Vector)persistOrderedKeys.getContents();
                        if (safetyTable == null)
                        {
                            safetyTable = new Hashtable();
    
                            persist.setContents(safetyTable);
                            persist.commit();
                        }
    
                        if (orderedKeys==null)
                        {
                            orderedKeys=new Vector();
    
                            if (safetyTable.size()>0)
                            {
                                Enumeration addressKeys = safetyTable.keys();
                                while(addressKeys.hasMoreElements())
                                {
                                    orderedKeys.addElement((String)addressKeys.nextElement());
                                }
                            }
                            persistOrderedKeys.setContents(orderedKeys);
                            persistOrderedKeys.commit();
    
                        }
    

    "I don't know if it's one thing to eclipse debugger.

    I had problems of this kind when I don't have a level of operating system for the device I am debugging on.

  • Null value? What the h is a Null value in my registry events?

    while I'm compensation of errors I have 1 last error, apparently harmless but annoying nonetheless, I want to get all these events "Null" out of my system.

    Log name: System
    Source: Service Control Manager
    Date: 23/02/2013-11:54:52
    Event ID: 7026
    Task category: no
    Level: error
    Keywords: Classic
    User: n/a
    Computer: INTL
    Description:
    The next (s) starting or starting system could not load:
    Null value
    The event XML:
    http://schemas.Microsoft.com/win/2004/08/events/event">
     
       
        7026
        0
        2
        0
        0
        0 x 8080000000000000
       
        9113
       
       
        System
        INTL
       
     

     
       
    Null value

     

    your help is appreciated, thanks

    Al Adams

    Hello

    Thanks for the reply.

    Your question does contain all the required information necessary for us to help you. Please provide us with more information to continue troubleshooting as a result.

    See the link on how to ask questions or help on the Forums.

    Suggestions for a question on help forums: http://support.microsoft.com/kb/555375

    Thank you.

  • How to implement 'Null value replace' inside a RTF

    Hello

    This is my area:

    <? for-each - group:current-group(); / RP_CURRENCY? >

    <? If: RP_CURRENCY = "ABOVE"? >

    <? for-each - group:current-group(); / RPT_DESCRIPTION? >

    <? If: RPT_DESCRIPTION = 'debit card '? >

    <? sum (current - group () / RP_CI_EQUIVALENT_CALC)? >

    <? end if? >

    <? end for each group -? >

    <? end if? >

    <? end for each group -? >

    If this field does not always reach the sum, and then returns a NULL value. I need it to return 0 instead, but I think I'm this overload since RTF are not flexible.

    I tried to reach '+ 0' at the end and it works when its null, but if the number is not null, then it adds a 0 to the result rather than adding it.

    The XML code is attached.

    Please use this amount

    And the code below will be more optimized for performance and maintenance.

Maybe you are looking for