Query of queries testing for null or empty dates

I'm having problems with this query (within a function). The
last condition in the where clause needs to check for an empty or
null date and then check against the current date (which is fine),
im aware that the syntax is wrong but wondered if someone could
correct it for me to get it working.
<cfquery name="filterQuery" dbtype="query"
maxrows="#arguments.top#">
select * from getAllSaved
where
workFlowStatusId = <cfqueryparam
cfsqltype="CF_SQL_INTEGER"
value="#application.const.WORKFLOW_LIVE#" />
and
dateArchive > <cfqueryparam cfsqltype="CF_SQL_DATE"
value="#now()#" />
and
dateLive <= <cfqueryparam cfsqltype="CF_SQL_DATE"
value="#now()#" />
and
(dateExpiry is null or dateExpiry = '') or dateExpiry >
<cfqueryparam cfsqltype="CF_SQL_DATE" value="#now()#" />
</cfquery>

I feel stupid, although i'd put a fiver on having tried that!
thanks

Similar Messages

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • Choice format for null or empty string vs non-empty

    How can I provide a choice format string for null or empty substitution strings?
    I know one would not nomally do this, but the substitution strings are being passed in by an independant legacy code. I need something equivalent to
    Some message with a choice {0,choice,null#nothing|not-null#something}
    Unfortunately, programatic implementation is not currently an option

    Ya, I will try that. That seems to be a good idea. Thanks for the response.
    I have one more query. Whenever we add a new column to any table in Oracle, the column name is stored in Upper case. So when we generate XML File from the database, all the tags are either in upper case (or we can use qry.useLowerCaseTagNames() to retrieve the tag names in lower case). But the XSD contains tag names in mixed case. So when validating the XML Document against an XSD, it throws a validation error.
    Is there any way I can avoid this?

  • Test for null result set

    I am trying to do a test for a null result set. Basically if the result set returns a value I want to display a table, otherwise I want to display an error message. The following code does not produce the error message. Either the test for null is incorrect, or for some reason I am not getting a null result set even when I don't enter any text into the following text boxes (this is for a login screen, these text boxes come a login screen):
    <input type="text" name="username">
    <input type="text" name="password">
    This is the code for the action page:
    <HTML>
    <%@page import="java.sql.*"%>
    <%
    //define connection
    Connection con = null;
    String user1 = request.getParameter("username");
    String pass1 = request.getParameter("password");
    String test = "good";
    try{
    //get the class
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //get the connection
    con = DriverManager.getConnection("jdbc:odbc:errorlog", "admin", "");
    //catch your exceptions!
    catch(Exception e){
         out.println(e.getMessage());
    %>
    <title>Error Application - Logged Errors</title>
    <link href="style/errorstyle.css" rel="stylesheet" type="text/css">
    <BODY>
    <%
    //define resultset and statement
    ResultSet rs=null;
    Statement stmt=null;
    try {
    //Using the current database connection create a statement
    stmt=con.createStatement();
    %>
    <%
    String sql="SELECT* FROM tblUsers" + " WHERE Username = '"+user1+"' AND Password ='"+pass1+"'";
    rs = stmt.executeQuery(sql);
    %>
    <% //Fetch all the records and print in table
    while(rs.next()){
    String user2 = rs.getString("FirstName");
    String pass2 = rs.getString("LastName");
    %>
    <table width="100%" border="0" cellspacing="1" cellpadding="6">
    <tr >
    <td width="67" height="27" bgcolor="#999999"><strong><font size="- 1">First Name</font></strong>
    </td>
    <td width="89" bgcolor="#999999"><strong><font size="-1">Last
    Name</font></strong>
    </td>
    </tr>
    <tr>
    <td>
    <%out.println(user2);%>
    </td>
    <td><%out.println(pass2);%></td>
    </table>
    <%}
    if (rs == null)
    out.println("Incorrect Username or Password");
    //close all your open resultsets, statements, and connection when you are done with them!
    rs.close();
    stmt.close();
    con.close();
    //catch all your exceptions
    catch (SQLException e) {
         out.println(e.getMessage());
    %>

    You simply test the rs.next().
    if ( rs.next() )
    //spit out the rs row and
    //continue processing the resultset 'til empty
    else
    msg = "invalid username or password
    }

  • Check for null or empty in the functoid

    I want to check for null and empty values on input source node. If there exists a null or empty in the input source node, I should not pass that to output destination node. Does the
    following attachment work? I want to check for null or empty in the date and time and then concatenate them to send to output. If any of them is null or empty, the other should not fail. In the Not Equal Functoid I am checking for blank, but how to check for
    null?

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • JSTL Core - How to test for null?

    How do I test an attribute for null using JSLT's if statement? The below code does not work (the JSTL if statement does not return true). The scriptlet however does work and displays the statement.
    - Chris
    index.jsp
    <%@ taglib uri="c.tld" prefix="c"%>
    <%@ taglib uri="fmt.tld" prefix="fmt"%>
    <%@page import="java.util.*"%>
    <%
       request.setAttribute("null", null);
    %>
    <html>
    <head>
      <title>JSTL Test Page</title>
    </head>
    <body>
    <c:if test="${null}==null">
    The value was null (JSTL)
    </c:if>
    <%
      if (request.getAttribute("null")==null) out.print("The value was null (Scriptlet)");
    %>
    </body>
    </html>
    <%out.flush();%>

    Well, I figured out. If anyone is interested, here is the code:
    <c:if test="${empty varName}">
      Its null
    </c:if>

  • Dropdown List Value Test For Null || " "

         I wrote a pre-sign script to test a for a value in a dropdown list before allowing signature of the document. However I want to test for a value of null in addtion to one space aka " ". I added a value in the dropdown list of " " along with the choices of names so users could erase an accidental selection in this list before they were ready. However when I place the or ( || ) operator in the if statement of the script the script doesn't work. If I remove the || " " statement the script works as it is supposed to. How do I test for this value of " " along with the null test so I don't have to write another if statement?
    if (form1.Page3.Author.Reviewed.Admin.rawValue == null || " ")
    xfa.event.cancelAction = 1
    xfa.host.messageBox("You did not select your name on the dropdown list before trying sign the document .");
    else

    Your if statement is incomplete. You need to put the test in again for the other value:
    if (form1.Page3.Author.Reviewed.Admin.rawValue == null || form1.Page3.Author.Reviewed.Admin.rawValue == " ")

  • Where condition to test for null

    Hi,
    I have a query where we were thinking that 2 fields will not have null values even though column allows nulls. So, wrote a query like this:
    select.......
    From table 1 left outer join table2 on (table1.name = 'I' and table2.accountnum in (table1.creditact, table1.debitact).
    Now I need to check for null if table1.creditact and table1.debitact. If both fields are null, then I have to use third column to check because out of 3 column (creditact, debitact, act) one must have account number. How can I do it.
    Thanks,
    Spunny

    I have a query where we were thinking that 2 fields [sic: columns are not fields] will not have NULL values [sic: NULL is not a value] even though column allows NULLs. So, wrote a query like this:
    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. What you did post implies that your design is wrong. Did you actually have debits and credits as separate attributes in RDBMS? No, surely not! I will guess, based 30+ years of SQL, that you have a crappy design
    with too many NULLs. 
    Would you like to obey the Netiquette so we can actually help you, or you do just want a Kludge? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Trying to test for null input

    I am trying to get some input from a user using:
    String name="";       
    BufferedReader in = new BufferedReader(
        new InputStreamReader(System.in));
    name = in.readLine();Let's say the user inputs nothing other than the enter key, how can I test for this so that I can write output for it?
    In Python, one would use something like:
    if not name:
         <then do something>Thanks,
    Harlin Seritt

    Thanks for the help. When I try it with an empty
    string test, nothing happens. However, the test of
    name.length() works perfectly. Thanks!
    Harlin SerittI'm guessing you tried this, right?
    if (name == "") ...
    That's not the way to compare string values. The == operator only compares object references when comparing 2 objects. It's an extremely common mistake.

  • Beginner question - testing for null string from shell script command

    I'm trying to test the result of a shell script command. I want to put out a message if the result is a null string. At present I get this applescript error "The command exited with a non-zero status"
    I'm sure this is a simple question ... but I can't figure out how to do it. Help!

    You can use try clause for the problem:
    set _result to ""
    try
    set _result to do shell script "/blah/andblah"
    end

  • Can you really use Display String formula to test for NULL

    I am trying to manipulate the Display String of a field throught the Format Editor.  If a field is null, it should display "N/A", or "No data given", or anything else appropriate I might choose.
    I can't get this feature to work and I'm wondering if there's a bug here.  I'm using the following formula:
    if (isnull() or    trim() = "")
    then "N/A"
        else
    Am I doing something wrong or is there a better way to do this?

    Hi Adriane
    The other way to display "N/A", or "No data given" if a field is null is using a formula with if -else statement as follows:
    whileprinting records;
    if (isnull() or trim () =" ")
    then "N/A"
    else
    Please let me know if this helps.
    Thanks
    Poonam Thorat

  • Check for Null vaules in query output

    I am querying a database for user info. I want to display the
    users e-mail address if there is one, if there is not an e-mail
    address, i want to alert the user of this, and offer them the
    chance to enter one. I figured i would use an if statement, but can
    figure out how to cod if 'email eq null'. The if statement is
    looking for the text null instead of a null

    what database engine u used?
    becauase difference database will have difference NULL
    definations.
    e.g MySQL
    <cfquery name="getuserinfo" datasource="websystem">
    select firstname, lastname, ifnull(email,'') as email
    from users
    where usernumber = #form.usernumber#
    </cfquery>
    <cfif getuseringo.email "">
    <cflocation url="emailnull.cfm">
    <cfelse>
    your e-mail address is
    <cfoutput>#getuseringo.email#</cfoutput>
    </cfif>
    u also might used <cfdump var=#[query result]#> to test
    the NULL value result.
    mostly will be this [empty string].
    then <cfif [query].[result] eq ""> should accept by
    CF

  • Searching for NULL with a FindPanel?

    Can I search for null values in my dataset using the FindPanel
    InfoBus control?
    From what I can gather, it actually puts together a primitive
    kind of where clause that I can trick to a certain extent (eg
    entering a criteria of "ANY (value, value,...)" to simulate an IN
    clause - because it will prepend the criteria with an equals
    sign), BUT I can't get it to find NULL values, which requires the
    IS NULL operator.
    Lachlan
    null

    We've found a workaround, which is ugly, but works.
    In the FindPanel, to successfully search for nulls, you can enter
    a combination of two conditions joined with an OR operator. For
    example, to search for members in the ACME_MEMBERS table with a
    null MID_INITIAL, I could enter the condition:
    = 'XXX' OR MID_INITIAL is null
    and then the WHERE clause will be:
    WHERE MID_INITIAL = 'XXX' OR MID_INITIAL is null
    which will find the rows I'm looking for.
    BUT, this is REALLY ugly, and there should be a better way.
    If anyone knows of a better way, please let me know.
    Lachlan
    Lachlan Williams (guest) wrote:
    : I am assuming that the FindPanel will call the associated
    : DataItem's setQueryCondition and then actually execute the
    query
    : for me, all happening when I press the Find button.
    : I can't see where in this paradigm there is an opportunity to
    : alter the where clause.
    : So to rephrase my original question: how can I explicitly test
    : for null values using the existing functionality of the
    FindPanel
    : control? (ie how do I get the IS NULL operator into the where
    : clause?).
    : Thanks,
    : Lachlan
    : JDeveloper Team (guest) wrote:
    : : Hi
    : : The FindPanel relies on RowSetInfo 's setQueryCondition. you
    : can
    : : try to directly use this method to set the query condition.
    : : regards
    : : Lachlan Williams (guest) wrote:
    : : : Can I search for null values in my dataset using the
    : FindPanel
    : : : InfoBus control?
    : : : From what I can gather, it actually puts together a
    primitive
    : : : kind of where clause that I can trick to a certain extent
    (eg
    : : : entering a criteria of "ANY (value, value,...)" to simulate
    : an
    : : IN
    : : : clause - because it will prepend the criteria with an
    equals
    : : : sign), BUT I can't get it to find NULL values, which
    requires
    : : the
    : : : IS NULL operator.
    : : : Lachlan
    null

  • Calender = empty date

    Hi,
    I am passing a Date value back to the user using WS,
    I would want to send instead of null an empty date, because null doesn't create a XML element, for sending empty elements in this field, I have to somehow set calender to empty date, is it possible.
    Can someone tell how to set the date to 0000-00-00 00:00:00 should be fine with me also
    thanks

    There's no such date. In particular there is no year zero.
    If you have a schema that doesn't permit null dates or no date, and you need to return a null date or no date, then one of the two is wrong. You really ought to get that fixed. But in the meantime you are going to have to choose a real date to mean "nothing" and have the consumer of that web service agree to treat it that way.

  • Testing for IS NOT NULL with left join tables

    Dear Experts,
    The query is showing the NULL rows in the query below....
    Any ideas, advice please? tx, sandra
    This is the sql inspector:
    SELECT O100321.FULL_NAME_LFMI, O100321.ID, O100404.ID, O100321.ID_SOURCE
    , O100404.NAME, O100321.PERSON_UID, O100404.PERSON_UID, O100404.VISA_TYPE
    FROM ODSMGR.PERSON O100321
    , ODSMGR.VISA O100404
    WHERE ( ( O100321.PERSON_UID = O100404.PERSON_UID(+) ) ) AND ( O100404.VISA_TYPE(+) IS NOT NULL )

    Hi Everyone,
    I am understanding alot of what Michael and Rod wrote.... I am just puzzled over the following:
    the query below is left joining the STUDENT table to
    HOLD table.
    The HOLD table - contains rows for students who have holds on their record.
    a student can have more than one hold (health, HIPAA, basic life saving course)
    BUT, for this query: I'm only interested that a hold exists, so I'm choosing MAX on hold desc.
    Selecting a MAX, helps me, bec. it reduces my join to a 1 to 1 relationship, instead of
    1 to many relationship.
    Before I posted this thread at all, the LEFT JOIN below testing for IS NOT NULL worked w/o
    me having to code IS NOT NULL twice....
    Is that because, what's happening "behind the scenes" is that a temporary table containing all max rows is being
    created, for which Discoverer has no predefined join instructions, so it's letting me do a LEFT JOIN and have
    the IS NOT NULL condition.
    I would so appreciate clarification. I have a meeting on Tues, for which I have to explain LEFT JOINS to the user
    and how they should create a query. I need to come up with rules.
    If I feel "clear", I asked my boss to buy Camtasia videocast software to create a training clip for user to follow.
    Also, if any Banner user would like me to email the DIS query to run on their machine, I would be glad to do so.
    thx sooo much, Sandra
    SELECT O100384.ACADEMIC_PERIOD, O100255.ID, O100384.ID, O100255.NAME, O100384.NAME, O100255.PERSON_UID, O100384.PERSON_UID, MAX(O100255.HOLD_DESC)
    FROM ODSMGR.HOLD O100255, ODSMGR.STUDENT O100384
    WHERE ( ( O100384.PERSON_UID = O100255.PERSON_UID(+) ) ) AND ( O100384.ACADEMIC_PERIOD = '200820' )
    GROUP BY O100384.ACADEMIC_PERIOD, O100255.ID, O100384.ID, O100255.NAME, O100384.NAME, O100255.PERSON_UID, O100384.PERSON_UID
    HAVING ( ( MAX(O100255.HOLD_DESC(+)) ) IS NOT NULL )
    ORDER BY O100384.NAME ASC

Maybe you are looking for