Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » Questions concering SQL Service
Questions concering SQL Service [message #1268439] Mon, 10 March 2014 10:00 Go to next message
Eclipse UserFriend
Scenario:
Column myCol of table MY_TABLE is nullable.
Value of myCol of row with primaryKey = 1 is null.

Code snippet:

    StringHolder myHolder = new StringHolder();

    SQL.selectInto(
        "SELECT myCol" +
        "FROM MY_TABLE " +
        "WHERE primaryKey = 1 " +
        "INTO :myColHolder"
        , new NVPair("myColHolder", myHolder);


Question:
Is this needed?
if (myHolder != null) {....};


At first glance it might not be, because of
    StringHolder myHolder = new StringHolder();


General Question, could parameters being passed to NVPair be set to null?
How do I verify if a column value is empty string or null?
What is the use of the NVPair constructor
  public NVPair(String name, Object value, Class nullType) {
    m_name = name;
    m_value = value;
    m_nullType = nullType;
  }


and the method
getNullType()


TIA
Daniele
Re: Questions concering SQL Service [message #1268524 is a reply to message #1268439] Mon, 10 March 2014 12:16 Go to previous messageGo to next message
Eclipse UserFriend
This is a quick answer, I did not verify it

If the value returned by your database is NULL (the database null), your holder instance will not be null (as you assumed).

I think, the value will be null (the java null):
myHolder.getValue()



For your question about NULL versus empty String, I think you should try it. It might also depend on the Database engine. What are you using? MySQL?



I can remember of one usecase where the nullType parameter is usefull: when you pass a value to the SQL engine directly (as input parameter).
//with myDate beeing a java.util.Date

SQL.selectInto(
        "INSERT INTO myTable (myCol) " +
        "VALUES (:myColHolder) "
        , new NVPair("myColHolder", myDate);


If myDate can be null, the NVPair cannot find out the type of myDate when it is null. This is because the type of null in Java is not known.("x instanceof SomeClass" is false if x is null)

In this case you will need something like:
new NVPair("myColHolder", myDate, Date.class);



If you need more information, feel free to tell. I could look deeper into it.
Re: Questions concering SQL Service [message #1269023 is a reply to message #1268524] Tue, 11 March 2014 05:34 Go to previous message
Eclipse UserFriend
Hi Jeremie

Many thanks for your super fast answer.

Daniele
Previous Topic:Unique field Id (Class Id) with aditional attributes for RCP Jubula Tests
Next Topic:Sort and preselect in SmartFields
Goto Forum:
  


Current Time: Wed Jul 23 09:53:09 EDT 2025

Powered by FUDForum. Page generated in 0.03132 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top