Query returns zero records in coldfusion context, but works fine in Navicat

I've got a query that's returning zero records when I load a page.  If I copy and paste that same query (from the debug output) into navicat, I get rows returned (as I expect).  Has anyone seen this?  It happens locally (CF9) AND remotely on our staging server (CF10).  Even weirder, it's a query that was previously working fine - I simply added an if statement to the where clause, and all of a sudden... 
Here's the query:
        <CFQUERY name="LOCAL.getEncounterServices" datasource="#REQUEST.dsn#"> 
        SELECT
            a.EncounterProductID,
            a.DateTime AS ServiceDate,
            aa.CartItemID,
            aaa.CartID,
            aaaaa.CartStatus,
            b.ProductID,
            b.ProductName,
            b.CPTCode,
            b.Price,
            c.EncounterID,
            c.DateTimeClosed AS EncounterClosedDate,
            d.FirstName,
            d.LastName
        FROM
            EncounterProducts a
                LEFT JOIN CartItemProduct aa ON (a.EncounterProductID = aa.EncounterProductID AND aa.Active = 1)
                LEFT JOIN CartItem aaa ON (aa.CartItemID = aaa.CartItemID)
                LEFT JOIN Cart aaaa ON (aaa.CartID = aaaa.CartID)
                LEFT JOIN CartStatus aaaaa ON (aaaa.CartStatusID = aaaaa.CartStatusID),
            Product b,
            Encounters c,
            Contacts d,
            EncounterStatuses e
        WHERE
            1 = 1
            AND (aa.CartItemID IS NULL OR aaaaa.CartStatus = 'Deleted')
            AND a.Active = 1
            AND a.ProductID = b.ProductID
            AND a.EncounterID = c.EncounterID
            AND c.PatientID = d.ContactID
            AND c.EncounterStatusID = e.EncounterStatusID
            AND e.EncounterStatus = 'Closed'
          <CFIF IsDefined("ARGUMENTS.encounter") AND IsObject(ARGUMENTS.encounter)>
                 AND c.EncounterID = <CFQUERYPARAM cfsqltype="cf_sql_integer" value="#ARGUMENTS.encounter.getID()#">
         <CFELSE>
                AND c.DateTimeClosed >= <CFQUERYPARAM cfsqltype="cf_sql_date" value="#ARGUMENTS.startDate#">
                AND c.DateTimeClosed < <CFQUERYPARAM cfsqltype="cf_sql_date" value="#DateFormat(DateAdd('d', 1, ARGUMENTS.endDate), 'yyyy-mm-dd')# 00:00:00">
           </CFIF>
            AND c.LocationID = <CFQUERYPARAM cfsqltype="cf_sql_integer" value="#ARGUMENTS.locationID#">
            AND c.CustomerID = <CFQUERYPARAM cfsqltype="cf_sql_integer" value="#ARGUMENTS.customerID#">
        </CFQUERY>
All of this worked just fine before I added the lines:
         <CFIF IsDefined("ARGUMENTS.encounter") AND IsObject(ARGUMENTS.encounter)>
                 AND c.EncounterID = <CFQUERYPARAM cfsqltype="cf_sql_integer" value="#ARGUMENTS.encounter.getID()#">
         <CFELSE>
                AND c.DateTimeClosed >= <CFQUERYPARAM cfsqltype="cf_sql_date" value="#ARGUMENTS.startDate#">
                AND c.DateTimeClosed < <CFQUERYPARAM cfsqltype="cf_sql_date" value="#DateFormat(DateAdd('d', 1, ARGUMENTS.endDate), 'yyyy-mm-dd')# 00:00:00">
          </CFIF>
Previously, it had just been:
                AND c.DateTimeClosed >= <CFQUERYPARAM cfsqltype="cf_sql_date" value="#ARGUMENTS.startDate#">
                AND c.DateTimeClosed < <CFQUERYPARAM cfsqltype="cf_sql_date" value="#DateFormat(DateAdd('d', 1, ARGUMENTS.endDate), 'yyyy-mm-dd')# 00:00:00">
With no IF/ELSE statement.
Anyone seen anything like this before?  Any ideas? 
Thanks.

Right, I'll start disabusing myself of the DateFormat!
I'm sorry, I should've posted the actual query too.  It's inserting the first part - "AND c.EncounterID = ....."
Here's the full query:
LOCAL.getEncounterServices (Datasource=xmddevdb, Time=9ms, Records=0) in /Applications/ColdFusion9/wwwroot/XMD_NEW/xmd_dev/cfc/ShoppingGateway.cfc @ 16:56:28.028
SELECT
            a.EncounterProductID,
            a.DateTime AS ServiceDate,
            aa.CartItemID,
            aaa.CartID,
            aaaaa.CartStatus,
            b.ProductID,
            b.ProductName,
            b.CPTCode,
            b.Price,
            c.EncounterID,
            c.DateTimeClosed AS EncounterClosedDate,
            d.FirstName,
            d.LastName
        FROM
            EncounterProducts a
                LEFT JOIN CartItemProduct aa ON (a.EncounterProductID = aa.EncounterProductID AND aa.Active = 1)
                LEFT JOIN CartItem aaa ON (aa.CartItemID = aaa.CartItemID)
                LEFT JOIN Cart aaaa ON (aaa.CartID = aaaa.CartID)
                LEFT JOIN CartStatus aaaaa ON (aaaa.CartStatusID = aaaaa.CartStatusID),
            Product b,
            Encounters c,
            Contacts d,
            EncounterStatuses e
        WHERE
            1 = 1
            AND (aa.CartItemID IS NULL OR aaaaa.CartStatus = 'Deleted')
            AND a.Active = 1
            AND a.ProductID = b.ProductID
            AND a.EncounterID = c.EncounterID
            AND c.PatientID = d.ContactID
            AND c.EncounterStatusID = e.EncounterStatusID
            AND e.EncounterStatus = 'Closed'
                 AND c.EncounterID = ?
            AND c.LocationID = ?
            AND c.CustomerID = ?
Query Parameter Value(s) -
Parameter #1(cf_sql_integer) = 28
Parameter #2(cf_sql_integer) = 16
Parameter #3(cf_sql_integer) = 6
Thansk again for the help!

Similar Messages

  • KPI's Score cannot show in one context but works fine in another scorecard

    Dear experts,
    We are now working on SSM 10.1 SP07, and we encountered a issue that the same measure cannot display the score value in one scorecard,so
    we have created a new scorecard and add these measures,all works fine, any ideas from you? thanks very much!
    best wishes,
    Yanping.li

    Hi,
    Sometimes it is not that measure which is causing problem, their are chances that due to some other measure you are unable to see the score or status.
    Can you see the score of that particular KPI in the KPI detail view. ?
    To test , try to put all same measures and see if all the score is coming.
    Reg
    Mo

  • 0fi_ar_4 INIT returning zero records

    Hi gurus,
    0fi_ar_4 INIT is returning zero records while loading into ODS.I have checked in RSA3 it is returning zero records with INIT selection but is it is fetching records with Full update.Can ne one tell me what to do.how to solve this problem.
    rgds,
    ***Points Assured**

    Hi Suravi,
    Check at the Info Package selection-- Init with out data transfer.
    Make it with data transfer..
    Hope it helps..

  • Global Temp Table, always return  zero records

    I call the procedure which uses glbal temp Table, after executing the Proc which populates the Global temp table, i then run select query retrieve the result, but it alway return zero record. I am using transaction in order to avoid deletion of records in global temp table.
    whereas if i do the same thing in SQL navigator, it works
    Cn.ConnectionString = Constr
    Cn.Open()
    If FGC Is Nothing Then
    Multiple = True
    'Search by desc
    'packaging.pkg_msds.processavfg(null, ActiveInActive, BrandCode, Desc, Itemtype)
    SQL = "BEGIN packaging.pkg_msds.processavfg(null,'" & _
    ActiveInActive & "','" & _
    BrandCode & "','" & _
    Desc & "','" & _
    Itemtype & "'); end;"
    'Here it will return multiple FGC
    'need to combine them
    Else
    'search by FGC
    SQL = "BEGIN packaging.pkg_msds.processavfg('" & FGC & "','" & _
    ActiveInActive & "','" & _
    BrandCode & "',null,null); end;"
    'will alway return one FGC
    End If
    ' SQL = " DECLARE BEGIN rguo.pkg_msds.processAvedaFG('" & FGC & "'); end;"
    Stepp = 1
    Cmd.Connection = Cn
    Cmd.CommandType = Data.CommandType.Text
    Cmd.CommandText = SQL
    Dim Trans As System.Data.OracleClient.OracleTransaction
    Trans = Cn.BeginTransaction()
    Cmd.Transaction = Trans
    Dim Cnt As Integer
    Cnt = Cmd.ExecuteNonQuery
    'SQL = "SELECT rguo.pkg_msds.getPDSFGMass FROM dual"
    SQL = "select * from packaging.aveda_mass_XML"
    Cmd.CommandType = Data.CommandType.Text
    Cmd.CommandText = SQL
    Adp.SelectCommand = Cmd
    Stepp = 2
    Adp.Fill(Ds)
    If Ds.Tables(0).Rows.Count = 0 Then
    blError = True
    BlComposeXml = True
    Throw New Exception("No Record found for FGC(Finished Good Code=)" & FGC)
    End If
    'First Row, First Column contains Data as XML
    Stepp = 0
    Trans.Commit()

    Hi,
    This forum is for Oracle's Data Provider and you're using Microsoft's, but I was curious so I went ahead and tried it. It works fine for me. Here's the complete code I used, could you point out what are you doing differently?
    Cheers,
    Greg
    create global temporary table abc_tab(col1 varchar2(10));
    create or replace procedure ins_abc_tab(v1 varchar2) as
    begin
    insert into abc_tab values(v1);
    end;
    using System;
    using System.Data;
    using System.Data.OracleClient;
    class Program
        static void Main(string[] args)
            OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger");
            con.Open();
            OracleTransaction txn = con.BeginTransaction();
            OracleCommand cmd = new OracleCommand("begin ins_abc_tab('foo');end;", con);
            cmd.Transaction = txn;
            cmd.ExecuteNonQuery();
            cmd.CommandText = "select * from abc_tab";
            OracleDataAdapter da = new OracleDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            Console.WriteLine("rows found: {0}", ds.Tables[0].Rows.Count);
            // commit, cleanup, etc ommitted for clarity
    }

  • Using index in a query return few records than full table access

    Today we have an issue with a query, when it use the ok index the returned are not all records that apply to where clause condition.
    See bellow
    explain plan for
    select * from movdb.zan_m03 where
    M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
    M00za = 10 AND
    m00AC = 50 AND
    M00AD between 136906 and 136999
    SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1882720105
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | TABLE ACCESS BY INDEX ROWID| ZAN_M03 |
    |* 2 | INDEX RANGE SCAN | PK_ZAN_M03 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
    2 - access("M00AF"=TO_DATE('11/01/28','YY/MM/DD') AND "M00ZA"=10 AND
    "M00AC"=50 AND "M00AD">=136906 AND "M00AD"<=137141)
    filter("M00AD"<=137141 AND "M00AD">=136906)
    Note
    - rule based optimizer used (consider using cbo)
    20 rows selected.
    The query above return only one row insted 1579 record that apply to this conditions.
    When forcing a full table acess with a hint, the query return all records that apply, the 1579 record.
    select /*+ FULL(zan_m03) */ M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
    M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
    M00za = 10 AND
    m00AC = 50 AND
    M00AD between 136906 and 137141
    Can you help me to identify what's happening?
    I am with Oracle 10g R2 10.2.0.4 standard edition
    the statistics are up to date
    the opitimizer_mode are rule, but altering in session level to all_rows happens the same issue.
    Nothing about corruption in the alert log.
    Thanks in advance
    Regards
    Cristiano

    Yes the query are the same and correct restriction for where clause are M00AD between 136906 and 137141.
    I've pasted, by mistake, another test query
    The corrects are:
    select M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
    M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
    M00za = 10 AND
    m00AC = 50 AND
    M00AD between 136906 and 137141
    This use pk index and return one row
    select /*+ FULL(zan_m03) */ M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
    M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
    M00za = 10 AND
    m00AC = 50 AND
    M00AD between 136906 and 137141
    This does a full table access and return 1579 records
    I´ve been searching for wrong results bugs on my oracle support, but not found one that mentions something like our issue.
    I checked the dba_tables and dba indexes and the number of rows are different, and I think this would be the same because it's is a pk.
    Look this
    SQL> select NUM_ROWS from dba_tables where table_name = 'ZAN_M03'
    2 /
    NUM_ROWS
    228527878
    select NUM_ROWS from dba_indexes where index_name = 'PK_ZAN_M03';
    SQL> select NUM_ROWS from dba_indexes where index_name = 'PK_ZAN_M03';
    NUM_ROWS
    217510185
    Is normal a index for pk having much fewer rows than table? I think not, but not sure.
    Again
    Thanks in advance
    Regards
    Cristiano

  • I have a Mac running 10.9.2. My wireless mouse with not scroll in mail but works fine in other applications? Any suggestions?

    I have a Mac running 10.9.2. My apple wireless mouse will not scroll in Mail but works fine in other applications.
    Any suggestions?

    First, see this discussion. If the solution suggested there doesn't work for you, continue.
    If you've installed a Mail plugin called "Mail Unread Menu" and you know how to remove it, please do that, then quit and relaunch Mail. Test. Otherwise, see below.
    Back up all data.
    1. Triple-click anywhere in the line below on this page to select it:  
    ~/Library/Mail/Bundles
    Right-click or control-click the highlighted line and select 
    Services ▹ Open
    from the contextual menu.* A folder may open, or you may get an error message that the item can't be found. Either result is normal. If the folder does open and has contents, move the contents to the Desktop. Relaunch Mail and test. If there's no change, put the contents of the folder back and quit Mail again.
    2. Repeat with this line:
    /Library/Mail/Bundles
    This time you may be prompted for your login password when you remove the items. Make sure they're removed from the folder and not just copied to the Desktop. If necessary, copy them first and then move the originals to the Trash.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.

  • BDC for ME22N not working in background but working fine in foreground

    Hi guys,
    I have done a BDC recording for ME22N.
    Its working fine in foreground but failing in background.
    Can anyone sugesst a solution.
    Thanks!

    There is a note on this subject, BDC with control may (and of course will) not perform correctly in background, they need the Sapgui) [Note 381630 - Batch input for Enjoy transaction in MM not possible|https://service.sap.com/sap/support/notes/381630]
    You may need to use the old ME22 transaction or BAPI like BAPI_PO_CHANGE [Note 217437 - ME21N/ME51N: Batch input and CATT not possible|https://service.sap.com/sap/support/notes/217437]
    Regards
    Regards

  • HT1414 touch screen does not work on my ipod when playing music on itunes, but works fine on every other thing on ipod

    touch screen does not work on my ipod when playing music on itunes, but works fine on every other thing on ipod, can anyone help or what is the cause

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Unsync all music and resync
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar          

  • My iphone5 wont charge with usb port but works fine with wall plug... Infact computer. Doesn't recognizes the iphone

    Battery not charging with usb port but works fine with wall plug.. So the prob is computer is not detecting the iphone5 . This problem started after upgrading to 6.1.3 version

    Try to see what happens on another computer. If it works on another computer, the issue is not at the iPhone.

  • Superdrive no longer recognizes CD, but works fine with DVD

    my Superdrive seems to have a problem recognizing any type of CD media, but works fine with DVD media.
    I reinstalled Leopard and still the same problem. I also zapped the NVRAM (this is an Intel 2.0 Ghz Mac Mini w/ 2 GB Ram.
    Is there anything else I can do or do I just need to replace the drive?

    Typically when this sort of symptom appears, it relates to a hardware failure, either due to a faulty lens, or dirt. You might try a lens cleaner to ensure it is not the latter.
    Since this is a 2.0GHz mini, it ought to be still under warranty - if that is the case it would be wise to have Apple, or an approved service provider, check it and undertake any necessary repairs.

  • People picker is not working for ie11 but working fine for other lower version

    i am using sharepoint 2010 and windows authentication
    recently i have updated my ie to ie11 and problem goes here.
    when i try to select from people picker, there are an unexpected error happened 
    however when i use other ie version, people picker work fine, what goes wrong?
    i have already added my system as trusted site
    if there any others thing i miss out?

    Hi,
    According to your post, my understanding is that People picker is not working for ie11 but working fine for other lower version.
    IE 11 is known to have compatibility issues on SharePoint 2010, please make sure to:
    first of all, try installing latest update for IE 11 (several compatibility issues were fixed since the first release)
    add the site to compatibility view (in IE> Tools> Compatibility view settings> type site name> add)
    add the site to trusted sites and set the zone security level to low (in IE> Internet Options> Security> trusted sites> sites>add your site there> ok> custom level> select low> reset> ok)
    You can use developer tools (f12) and set browser mode to the version that is most compatible with your environment.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • BPEL process fails in SOA (in UNIX), but works fine in SOA (in Windows) env

    Hello,
    BPEL process fails in SOA (in UNIX), but works fine in SOA (in Windows) environment
    Step 1: Build a asynchronous BPEL process which has no extra node. Make and deploy it in 'local windows desktop SOA' server
    The BPEL process has three nodes:
    a. client - on the left side of the swim lane
    b. receiveInput - first node in swim lane (client calls 'receiveInput')
    c. callbackClient - second and last node in the swim lane ('callbackClient' calls client)
    Step 2: Go to BPEL console and 'Initiate' the BPEL process -> 'Post XML Message'
    Step 3: Now, I can see the successfully completed BPEL instance in the BPEL console.
    Now,
    Step 4: Deploy the same BPEL process (dummy asynchronous) in the SOA server (hosted in unix box)
    Step 5: Go to BPEL console and 'Initiate' the BPEL process -> 'Post XML Message'
    Step 6: I find that the BPEL instance appears to have ended in error (on the second node i.e. callbackClient )
    With the following error message
    +<invalidVariables xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>9710</code>+
    +</part><part name="summary"><summary>Invalid xml document.+
    According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-complex-type.2.4.b: The content of element 'DummyBPELProcessProcessResponse' is not complete. One of '{"http://xmlns.oracle.com/DummyBPELProcess":result}' is expected.
    Please make sure that the xml document is valid against your schemas.
    +</summary>+
    +</part></invalidVariables>+
    Has anyone faced similar issue as above ?
    i.e. process works find in windows environment (local SOA), but fails in SOA server in UNIX environment
    Appreciate your help in understanding this issue.
    Thanks,
    Santhosh

    Hello,
    The fix to this issue appears to have been as follows:
    +<schema attributeFormDefault="unqualified"+
    +     elementFormDefault="qualified"+
    +     targetNamespace="http://xmlns.oracle.com/DummyBPELProcess"+
    +     xmlns="http://www.w3.org/2001/XMLSchema">+
    +     <element name="DummyBPELProcessProcessRequest">+
    +          <complexType>+
    +               <sequence>+
    +                    <element name="input" type="string"/>+
    +               </sequence>+
    +          </complexType>+
    +     </element>+
    +     <element name="DummyBPELProcessProcessResponse">+
    +          <complexType>+
    +               <sequence>+
    +                    <element name="*:result*" type="string"/>+
    +               </sequence>+
    +          </complexType>+
    +     </element>+
    +</schema>+
    In DummyBPELProcess.xsd,
    modifiying "result" to ":result" appears to have resolved the issue in SOA under unix environment.
    If anyone can explain why "result" works in SOA under windows and ":result" works in SOA under unix environment, I would really appreciate your help.
    Thanks,
    Santhosh

  • I just installed CC Lr 5.5 and it will not open on my laptop but works fine on my desktop.

    I just installed CC Lr 5.5 and it will not open on my laptop, but works fine on my desktop.

    Try this:
    https://helpx.adobe.com/lightroom/kb/unable-launch-lightroom-55.html

  • TS2972 First night I was able to watch 2 TV shows (45 min each) with no problems, but thereafter programs will not stream without constant pause to buffer. Weather conditions are ideal and my internet comes from crappy hugesnet, but worked fine the first

    First night I was able to watch 2 TV shows (45 min each) with no problems, but thereafter programs will not stream without constant pause to buffer. Weather conditions are ideal and my internet comes from crappy hugesnet, but worked fine the first night.

    The speed may have been ok at that time and is too inconsistent/too slow overall. interference may have proven to be more of an issue since as well. If using public DNS that will provide Intermittant results
    I'm sure using a hotspot would be fine but it depends on your viewing habits. An HD movie is around 4-5GB. It would also be subject to speed. requirements so best to test to see how it compares.
    You would have to check with your Carrier if hotspot it's enabled then just to into your settings and toggle it ON

  • Newest version of flash player not playing in newest version of google chrome but works fine in IE

    newest version of flash player not playing in newest version of google chrome but works fine in IE

    jennifer.jones214 wrote:
    In your  opinion, should I uninstall Firefox if I am installing Waterfox?
    Waterfox can coexist peacefully with Waterfox.  I have both installed, but never use Firefox any more.
    Not only can Waterfox run in 64-bit address space, it also is better optimized during compile time than Firefox.  (For obvious reasons; Firefox is compatible with many old systems, Waterfox only needs to be compatible with new 64-bit systems.)
    P.S. regarding Chris' advice above; Firefox and Waterfox use the same profile, so if that is actually the problem, then it will occur in both browsers.

Maybe you are looking for

  • Blank Line in a query

    How to add a blank line in a query and it does not have to zeros... thanks

  • 9860 Bluetooth problems with car hands-free

    I have a Torch 9860 that has problems with my new 2012 Hyundai Santa Fe. I can pair it with the bluetooth in the car, and it will sometimes keep the connection on the next trip, but usually I get a 'connection failed' message. If I revert to the prev

  • Mail icon deleted

    My two year old son has managed to delete the icons on the bottom bar of the home screen (the ones the are always there), including Mail, safari, photos, etc. I can still access them through a search, but how can I get them back to my home screen? Th

  • App update and iOS 8.1.1

    Using an iPad2 with 64 gig, wifi, and cellular.  I downloaded iOS 8.1.1 on Monday and now find that the updates fron the iTunes store do not complete, often lockin out that app.  I have signed out and back in to the store, and also toggled airplane m

  • Problems Connecting NOMAD MuVo NX with Compu

    I received a present from london. A Nomad MuVo NX. I'm having problems connecting it to the computer. My computer won't detect it at all. I installed all the programs and drivers and everything I could think of. I can't get an icon on the LCD screen