Datagrid, Where Statement ?

Hello All.
I have a datagrid that pulls all its data from a database.
It has two colums - String and Visibile.
I would like to create a function, that acts as a "Where" statement.  Its function should look at the datagrid and set the value of a label.text to the String from the datagrid whos Visible value is yes.  Only one string can have a visible value of Yes, the rest are no.
So basically all its got to do is look thru the datagrid and set the text value of a label to the string of the item whos visible = Yes.
Im not sure if this can be done with a "Where" statement.
I have tried looking about on Google, but no luck.
Im not sure if i have explained this well enough.  Let me know if i havent.
Thanks

Hello,  Thanks again for the reply.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.collections.XMLListCollection;
            import mx.controls.Alert;
            import mx.events.FlexEvent;
            import mx.events.ListEvent;
            import mx.messaging.ChannelSet;
            import mx.messaging.channels.AMFChannel;
            import mx.messaging.events.MessageAckEvent;
            import mx.messaging.events.MessageEvent;
            import mx.messaging.messages.AsyncMessage;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.xml.SimpleXMLEncoder;
            import mx.utils.ObjectUtil;
            import org.osmf.events.TimeEvent;       
            import spark.events.TextOperationEvent;
            [Bindable] private var StringArr:ArrayCollection = new ArrayCollection(
                    [{id:"1", string:"String 1", vis:"no"},
                    {id:"2", string:"String 2", vis:"no"},
                    {id:"3", string:"String 3", vis:"no"},
                    {id:"2", string:"String 4", vis:"no"},
                    {id:"2", string:"String 5", vis:"yes"},
                    {id:"2", string:"String 6", vis:"no"},]);
            protected function getString():void
        ]]>
    </fx:Script>
    <mx:DataGrid x="10" y="34" dataProvider="{StringArr}" editable="true">
        <mx:columns>
            <mx:DataGridColumn headerText="ID" dataField="id"/>
            <mx:DataGridColumn headerText="String" dataField="string"/>
            <mx:DataGridColumn headerText="Vis" dataField="vis"/>
        </mx:columns>
    </mx:DataGrid>
    <s:Label x="10" y="184" id="VisString" width="210"/>
    <s:Button x="237" y="184" label="Get String" click="getString()"/>
</s:Application>
here is my code, for the sake of the example, i have removed the connection to the database and just added an array into the code.  But in real the array is pulled from the database.
Now what i want, when the user clicks the "Get String" button, i want the function "getString" to look at the datagrid's array and find the String that has the value vis:Yes.  I then want it to return the String associated with that into the text value of VisString.
So for example, when you click "Get String" the function sees that string 5 has the visible Yes, so the text value of  VisString should change to "String 5"
Hope you now understand what  i mean ?

Similar Messages

  • Query WHERE statement to compare db record date pt 2

    I'm sorry, I hit the answered button on my last post. I didn't mean to. I have been working on this code and have gotten closer to the solution. I just need to tweek out the WHERE statement to get rid of the time from the output, and I believe my cfif needs a little work to allow it to be taken into the actually dates. I cfdumped my variables from my query and finally got an output and not an [empty string]. This is my code now, and I will leave in the cfdump and abort tags so you can see where I put them:
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate Between #NextMonthYear# and #NextMonth# AND eventDate >= #dateFormat(Days, 'dd')#
    </cfquery>
    this is my cfif stement
    <cfoutput query="CaleventRec">
    <cfdump var="#eventDate#">
    <cfabort>
    <cfif Days EQ '#eventDate#'>
    <a href = "detail.cfm?id=#ID#">#Days#</a>
    </cfif>
    </cfoutput>
    this is the whole code:
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate Between #NextMonthYear# and #NextMonth# AND eventDate >= #dateFormat(Days, 'dd')#
    </cfquery>
                            <!--- Set the ThisDay variable to 0. This value will remain 0 until the day of the week on which the first day of the month falls on is reached. --->
                            <cfset ThisDay = 0>
                            <!--- Loop through until the number of days in the month is reached. --->
                            <cfloop condition = "ThisDay LTE Days">
                                <tr>
                                <!--- Loop though each day of the week. --->
                                <cfloop from = "1" to = "7" index = "LoopDay">
                                <!--- This turns each day into a hyperlink if it is a current or future date --->
                                  <cfoutput query="CaleventRec">
              <cfdump var="#eventDate#">
                                   <cfabort>
              <cfif Days EQ '#eventDate#'>
                                   <a href = "detail.cfm?id=#ID#">#Days#</a>
                                   </cfif>
              </cfoutput>
                                <!---
                                    If ThisDay is still 0, check to see if the current day of the week in the loop matches the day of the week for the first day of the month.
                                    If the values match, set ThisDay to 1.
                                    Otherwise, the value will remain 0 until the correct day of the week is found.
                                --->
                                    <cfif ThisDay IS 0>
                                        <cfif DayOfWeek(ThisMonthYear) IS LoopDay>
                                            <cfset ThisDay = 1>
                                        </cfif>
                                    </cfif>
                                <!---
                                    If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay
                                    the day of the mnth and increment the value.
                                --->
                                        <cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
                                        <cfoutput>
                                        <!--- I choose to highlight the current day of the year using an IF-ELSE. --->
                                            <cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
                                                <td align = "center" bgcolor="##FFFF99">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendartoday">#ThisDay#</font>
                                                </td>
                                            <cfelse>
                                                <td align = "center">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendar">#ThisDay#</font>
                                                </td>
                                            </cfif>
                                        </cfoutput>
                                        <cfset ThisDay = ThisDay + 1>
                                        <cfelse>
                                            <td></td>
                                    </cfif>
                                </cfloop>
                                </tr>
                        </cfloop>
    the output from the cfdump is this: the first event date in the month of june.
    I need this to match the thisday part of the code in the cfloop function through the days of the week.
    Can anyone help me figure this part out?
    thank you, and really sorry about the 2nd post. I just woke up and hit the wrong button. again, really sorry all.
    CFmonger

    This is a small calendar. it will move to the next month at the end of this one, it can also go to the next month with a next / prev button that will let you go as far as you want. It is like all we have seen before. What I need to do it get the eventDate in my DB, that is set as date and put in as mm/dd/yyyy now, basically what I believe the query needs to do it to not only tell what month the calendar is on, but it needs to match any db records with any of the days in that month. Say we are in June: I have 3 records in June, on the 5th, 20th, and 26th. In all the 31 days in the month of June, just those 3 will show a link with an ID to the record that matches in the DB.
    I had it narrowed down with that query, but lose the variable once I try and cfif it. So I knew either my query is wrong, or my cfif is, probably both.
    does that help? can I make this work? am I even close?
    thank you.
    CFmonger
    By the way, here is the entire code with the next / prev nav for cycling through the months.
    <!--- Declaration of the variables --->
           <cfparam name = "month" default = "#DatePart('m', Now())#">
    <cfparam name = "year" default = "#DatePart('yyyy', Now())#">
    <cfparam name = "currentday" default = "#DatePart('d', Now())#">
    <cfparam name = "startmonth" default = "#DatePart('m', Now())#">
    <cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">
    <!--- Set a requested (or current) month/year date and determine the number of days in the month. --->
    <cfset ThisMonthYear = CreateDate(year, month, '1')>
    <cfset Days = DaysInMonth(ThisMonthYear)>
    <!--- Set the values for the previous and next months for the back/next links.--->
    <cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
    <cfset LastMonth = DatePart('m', LastMonthYear)>
    <cfset LastYear = DatePart('yyyy', LastMonthYear)>
    <cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
    <cfset NextMonth = DatePart('m', NextMonthYear)>
    <cfset NextYear = DatePart('yyyy', NextMonthYear)>
    <cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
    <cfset CurrentYear = DatePart('yyyy', Now())>
    <table border="0" width="100%" bgcolor ="#ffffff">
                <tr>
                    <td align = "center" valign="top">
                        <table border="0" width="100%" height="100%">
       <tr>
          <th align="center" colspan="7" bgcolor="#2b4e6e">
       <cfoutput>
       <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="15%" align="left" valign="middle">
      <cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)>
    <cfelse>
      <a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
            <td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
            <td width="13%" align="right" valign="middle">
      <cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)>
    <cfelse>
    <a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a>  </cfif></td>
          </tr>
        </table></cfoutput></th>
       </tr>
       <tr>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>
       </tr>
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate Between #NextMonthYear# and #NextMonth# AND eventDate >= #dateFormat(Days, 'dd')#
    </cfquery>
                            <!--- Set the ThisDay variable to 0. This value will remain 0 until the day of the week on which the first day of the month falls on is reached. --->
                            <cfset ThisDay = 0>
                            <!--- Loop through until the number of days in the month is reached. --->
                            <cfloop condition = "ThisDay LTE Days">
                                <tr>
                                <!--- Loop though each day of the week. --->
                                <cfloop from = "1" to = "7" index = "LoopDay">
                                <!--- This turns each day into a hyperlink if it is a current or future date --->
             <cfoutput query="CaleventRec">
              <!---  <cfdump var="#eventDate#">
                                   <cfabort>--->
              <cfif #dateFormat(eventDate, 'dd')# IS ('Days, LoopDay')>
              <cfdump var="#eventDate#">
                                   <cfabort>
                                   <a href = "detail.cfm?id=#ID#">#Days#</a>
                                   </cfif>
              </cfoutput>
                                <!---
                                    If ThisDay is still 0, check to see if the current day of the week in the loop matches the day of the week for the first day of the month.
                                    If the values match, set ThisDay to 1.
                                    Otherwise, the value will remain 0 until the correct day of the week is found.
                                --->
                                    <cfif ThisDay IS 0>
                                        <cfif DayOfWeek(ThisMonthYear) IS LoopDay>
                                            <cfset ThisDay = 1>
                                        </cfif>
                                    </cfif>
                                <!---
                                    If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay
                                    the day of the mnth and increment the value.
                                --->
                                        <cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
                                        <cfoutput>
                                        <!--- I choose to highlight the current day of the year using an IF-ELSE. --->
                                            <cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
                                                <td align = "center" bgcolor="##FFFF99">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendartoday">#ThisDay#</font>
                                                </td>
                                            <cfelse>
                                                <td align = "center">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendar">#ThisDay#</font>
                                                </td>
                                            </cfif>
                                        </cfoutput>
                                        <cfset ThisDay = ThisDay + 1>
                                        <cfelse>
                                            <td></td>
                                    </cfif>
                                </cfloop>
                                </tr>
                        </cfloop>
                        </table>
                    </td>
                </tr>
            </table>

  • Using alias in where statement

    simple sql:
    SELECT EMPLOYEE_ID,
    FIRST_NAME,
    LAST_NAME,
    EMAIL,
    PHONE_NUMBER,
    HIRE_DATE,
    JOB_ID,
    SALARY,
    COMMISSION_PCT,
    MANAGER_ID,
    DEPARTMENT_ID
    FROM EMPLOYEES
    WHERE EMPLOYEE_ID > 1000;
    is it somehow possible to use alias in where statement like
    SELECT EMPLOYEE_ID "ID",
    FIRST_NAME,
    LAST_NAME,
    EMAIL,
    PHONE_NUMBER,
    HIRE_DATE,
    JOB_ID,
    SALARY,
    COMMISSION_PCT,
    MANAGER_ID,
    DEPARTMENT_ID
    FROM EMPLOYEES
    WHERE "ID" > 1000;

    Hi,
    is it somehow possible to use alias in where statement likeWhy do you need it?
    To answer your question "Not directly"
    SQL> select empno eno, sal
      2  from emp
      3  where eno = 7900;
    where eno = 7900
    ERROR at line 3:
    ORA-00904: "ENO": invalid identifierColumn Alias are names given to give meaningful names to columns or the arithmetic operations' column.
    Twinkle

  • Left outer join 3 tables with where-statement

    Hi folks,
    I hope you can understand (and maybe solve) my problem.
    Generally I try to left outer join three tables. The third table is used for a WHERE-statement.
    The three table structures are the following:
    table 1 (user)   
    user1 | key
    table 2 (detail)  
    key | ID
    table 3 (header)
    ID | user2                 
    ...and I want to achieve the following structure (as example filled with data):
    user | key | ID
    |-----|----
    xy    | a    | 001
    xy    | b    | #
    z     | b     | #
    The clue ist the usage of the third table. I need the table to set user1 and user2 equal (WHERE) but there are two problems:
    1) Obviously I can't left outer join two tables with each other. In this case I already used the 'key' of table 1 to join it with the 'key' of table 2. So I can't left outer join the 'ID' of table 2 with the 'ID' of table 3. Error message that I can only left outer join a table once. Any proposals?
    2) I have to include a WHERE to equal user1 with user2. But I am not allowed to use the user2 from table 3 because of the left outer join.
    I tried this coding:
    SELECT auser1 akey b~id INTO TABLE itab FROM ( table1 AS a
      LEFT OUTER JOIN table2 AS b ON akey = bkey )
      LEFT OUTER JOIN table3 AS c ON bID = cID )
      WHERE auser1 = cuser2.
    I would really appreciate your help.
    Regards
    MrclSpdl

    IF you want to join a DB table with an internal table, you need to use the 'FOR ALL ENTRIES' statement.
    select dbfields
    into table itab2
    from dbtab
    for all entries in itab
    where dbfield1 = itab-field1.
    This will get you a second internal table with all the corresponding data for the first selection.  You can then join them with a loop through the first table and a read table on the second table (for 1 - 1 relation) or a nested loop statement on both tables (for 1 - N relation).  Make itab a hashed table when using read table with key, use a sorted table if you need to loop without key access.
    Regards,
    Freek

  • I find it annoying that you can't use aliases in where statements

    I find it annoying that you can't use aliases in where
    statements
    for example:
    SELECT TOP 1
    CAST(amount
    / ( CASE WHEN ISNULL(rate, 0) <> 0 THEN rate
    ELSE 1
    END ) AS NUMERIC(10, 2)) AS num
    FROM table
    WHERE num > 1
    ORDER BY num
    Are there any workarounds?

    > I find it annoying that you can't use aliases in where
    statements
    This isn't really (or... "at all") a CF question. You're
    better off asking
    this sort of thing on a SQL Server forum.
    You could use a derived table, I guess:
    select top 1 num
    from (
    SELECT
    CAST(amount
    / ( CASE WHEN ISNULL(rate, 0) <> 0 THEN
    rate
    ELSE 1
    END ) AS NUMERIC(10, 2)) AS num
    FROM table
    where num > 1
    order by num
    (that might not preserve the intent of you SQL (sorry: it's
    late, I'm
    tired), but you get the idea.
    Adam

  • Group function is not allowed here - where statement

    I have a select that is basically:
    select a,b,
    sum(c),sum(d),
    sum(c) - sum(d)
    from A
    group by a, b
    I would like to add:
    where sum(c) - sum(d) <> 0
    I know that I can't use the sum function in the where statement.
    Any ideas how I can get around it?
    Thanks.
    Leah

    Hi ,
    for instance ... using the count aggregate function... which is the same as using sum function.....
    SQL> select job , cnt_emp , cnt_sal
      2    from
      3    (
      4      select job, count(empno) cnt_emp, count(sal) cnt_sal
      5        from emp
      6      group by job
      7    )
      8   where cnt_emp- cnt_sal=0
      9  /
    JOB                            CNT_EMP    CNT_SAL
    CLERK                                5          5
    SALESMAN                             5          5
    PRESIDENT                            1          1
    MANAGER                              3          3
    ANALYST                              2          2Greetings....

  • SQLQuery and Where-Statement

    Hi,
    I need a possibility to enter the where-statement at runtime.
    In the "SQL Query Statement" I can enter a query and parameters.
    My Problem ist that at runtime my forms-application builds the where-Part of the sql-statement and then sends it to the report.
    I know that reports has the &where_clause option.
    In &where_clause I can enter the whole where-clause of every statement.
    But how can I "tell" reports that it's query should based on this &where_clause???
    In other words: can I set the "sql Query Statement" at runtime?
    Thank you for your help
    bye
    Florian

    Hi Florian,
    In the data model, you can create a user parameter "P_WHERE" varchar2(1000), set your query like this:
    select col1,...coln
    from table
    where &P_WHERE;
    At the run time, you should pass the Where value from
    your form_application and send it to the parameter P_WHERE
    of the report.
    Hope this helps,
    CB

  • [PERSISTENCE CLASS] SELECT OPTION in WHERE statement

    Hi Gurus,
    I would like to know how could I code the WHERE statement with a SELECT OPTION, in Persistence Class ?
    Currenlty, I would like to code this kind of request :
              DELETE FROM      ziTab
                             WHERE   zdate IN so_date.      
    Do you know, how could I code it ?
    Many thx for helps.
    Best regards.
    Rachid.

    Sorry Glen,
    Unfortunately, I am trying to find the correct syntax to use a SELECT OPTION in a Query Request of Persistence Class:
    Something like that:
    SELECT-OPTIONS so_date     FOR    sy-datum                      .
    DATA lo_query_manager TYPE REF TO if_os_query_manager           .
    DATA lo_query         TYPE REF TO if_os_query                   .
    DATA lo_agent         TYPE REF TO zca_persistence_zint_rsbankinv.
    DATA lo_base          TYPE REF TO zcb_persistence_zint_rsbankinv.
    DATA lo_rsbankinv     TYPE REF TO zcl_persistence_zint_rsbankinv.
    DATA lo_table         TYPE        osreftab                      .
    DATA ls_table         TYPE REF TO zcl_persistence_zint_rsbankinv.
    DATA ls_tmp           TYPE REF TO object                        .
    DATA lv_string        TYPE        string                        .
    DATA lo_exception     TYPE REF TO cx_root                       .
    TRY .
       lo_agent    = zca_persistence_zint_rsbankinv=>agent.
    * Create Query
       lo_query_manager = cl_os_system=>get_query_manager( ).
       lo_query         = lo_query_manager->create_query( i_filter     = 'ZEXDAT IN PAR1' ).
       lo_table         =
       lo_agent->if_os_ca_persistency~get_persistent_by_query(
       i_query = lo_query
       i_par1  =  so_date
       LOOP AT lo_table INTO ls_tmp.
         ls_table ?= ls_tmp        .
         lv_string = ls_table->zget_all_fields( ).
         WRITE lv_string.
       ENDLOOP.
    CATCH cx_root INTO lo_exception.
       lv_string = lo_exception->get_text( ).
       WRITE lv_string.
    ENDTRY.
    But I have an error message :
    Syntax error when parsing a query : Excepected symbol 'IN' (row: O, column: 7)
    Any idea ?

  • Trigger fails when variable used in WHERE statement

    I have a trigger that works when the following statment is in it:
    SELECT custcall.callrkey into v_callrkey from custcall where custcall.servno = 152345;
    But the trigger fails when I attempt to use a variable in the where statement as follows.
    SELECT custcall.callrkey into v_callrkey from custcall where custcall.servno = :new.servno ;
    Even though I have verified that the value of :new.servno is set to 152345 by outputting the value . That is the only difference between the working version and the non-working version. By not working I mean that the email which is to be sent by the trigger is not received.
    Can anyone give me any ideas of how I could troubleshoot this or what might me happening? I'm pretty new to this and
    feel that I'm missing something very simple. My apologies in advance if this has been posted elsewhere. I did spend a lot of time searching the forum before posting.
    This is Oracle 9i.
    Thanks!
    Full code probably not necessary but posted below just in case:
    create or replace
    TRIGGER EMAILNOTIFY_NEW_SR
    AFTER INSERT ON CUSTPROB
    FOR EACH ROW
    DECLARE
    --SMTP Variables
    vreply utl_smtp.reply;
    vreplies utl_smtp.replies;
    mailCONN utl_smtp.connection;
    mailHOST VARCHAR2(64) ;
    --MESSAGE Variables
    mailText VARCHAR2(64);
    mailFROM VARCHAR2(64);
    mailTO VARCHAR2(64);
    mailDATE VARCHAR2(20);
    v_servno number ;
    v_callrkey number ;
    --PROGRAM Variables
    i number;
    BEGIN
    --get some values from the database  
    --set values for variables...
    mailHOST:= '10.35.173.15'; --this will always stay the same 
    mailFROM := 'Facilities_Customer_Service_Center'; --this will always stay the same
    mailTO := '[email protected]';
    SELECT custcall.callrkey into v_callrkey from custcall where custcall.servno = :new.servno  ;
    SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') INTO mailDATE FROM dual;
    dbms_output.put_line('open_connection');
    dbms_output.put_line('---------------');
    vreply := utl_smtp.open_connection(mailHOST, 25, mailCONN);
    dbms_output.put_line('helo');
    dbms_output.put_line('----');
    vreply := utl_smtp.helo(mailCONN, mailHOST);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    dbms_output.put_line('mail');
    dbms_output.put_line('----');
    vreply := utl_smtp.mail(mailCONN, mailFROM);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    dbms_output.put_line('rcpt to');
    dbms_output.put_line('----');
    vreply := utl_smtp.rcpt(mailCONN, mailTO);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    dbms_output.put_line('open_data');
    dbms_output.put_line('---------');
    vreply := utl_smtp.open_data(mailCONN);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    --SMTP ENVELOPE STUFF (In case it is needed later).  
    --utl_smtp.write_data(mailCONN, 'From:'  ||mailFROM     || chr(13));
    -- utl_smtp.write_data(mailCONN, 'To: '||mailTo || chr(13));
    --utl_smtp.write_data(mailCONN, 'CC:      '||mailFROM     || chr(13));
    --utl_smtp.write_data(mailCONN, 'Date:    '||mailDATE     || chr(13));
    --utl_smtp.write_data(mailCONN, 'BCC:     '||mailFROM     || chr(13));
    --THE MESSAGE
    utl_smtp.write_data(mailCONN, 'Subject: '||'Your Facilities Service Request ' ||'(SR '||v_servno||')'|| chr(13));
    utl_smtp.write_data(mailCONN, '');
    utl_smtp.write_data(mailCONN, '');
    utl_smtp.write_data(mailCONN, 'Dear Customer ' || chr(13));
    utl_smtp.write_data(mailCONN, '');
    utl_smtp.write_data(mailCONN, 'This is to inform you of something.' || ' ' ||mailTO|| chr(13) );
    utl_smtp.write_data(mailCONN, 'Please call us with any questions or concerns. ' || '' || chr(13));
    --DEBUG
    utl_smtp.write_data(mailCONN, 'DEBUG: ' || ''|| chr(13));
    utl_smtp.write_data(mailCONN, 'v_Servno ' || v_servno || chr(13));
    utl_smtp.write_data(mailCONN, 'v_callrkey ' || v_callrkey || chr(13));
    --END THE MESSAGE
    dbms_output.put_line('close_data');
    dbms_output.put_line('----------');
    vreply := utl_smtp.close_data(mailCONN);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    dbms_output.put_line('quit');
    dbms_output.put_line('----');
    vreply := utl_smtp.quit(mailCONN);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    END;

    Justin,
    Thanks for the reply. I'm away for a couple of days but when I get back to this I'm going to follow up on your suggestion about servno. I'm starting to think that the issue isn't with servno but rather that the select query doesn't return anything because the value I'm trying to get is in another table and is not being inserted in time for me to get them. This will be easiy enough to test. To be honest, I don't know very much about how things are being inserted.
    I appreciate your and Tubby's (and Tom's) concerns. Maybe I'll go back to the drawing board next week. But note that I'm not inserting anything with this trigger--only sending an email based on the insert that is happening through an application. So unless I'm really missing it, my email is dependent on the insert but not vice versa. Since my email is absolutely critical but rather jus a courtesy thing, I was taking a pretty laid back attitude about it but it would be good for me to learn a better way.
    Thanks again to all! I'll report back what I find/decide.

  • Nav attribute in where-statement

    Hi Experts,
    I have a routine in which I want to select 0MAT_SALES where my navigation attribute ZACCASGRP equals some values. I have written the code below but I get a syntax error when trying to compile it. I do not get any suggestions and I have not been able to figure out the problem.
    data: BEGIN OF Z_FUNDGROUP occurs 0,
        /BI0/OIMAT_SALES TYPE /BIC/AZBILCOPA00-MAT_SALES,
    END OF Z_FUNDGROUP.
    SELECT * FROM /BIC/AZBILCOPA00
        Into corresponding fields of table Z_FUNDGROUP
            where MAT_SALES-ZACCASGRP IN ('a', 'b', 'c').
    My problem is the where-statement and I have also tried with the following combinations but non of them works:
    /BI0/OIMAT_SALES-ZACCASGRP
    /BI0/OIMAT_SALES-0MAT_SALES__ZACCASGRP
    MAT_SALES-0MAT_SALES__ZACCASGRP
    if I change it to only say: where MAT_SALES IN ('a', 'b', 'c'). I do not get the error (but this is of course useless since I am not restricting on my navigation attrivute).
    Can somebody please help me with this.
    Thank you in advance,
    Mikael

    Hi,
    You are probably right regarding the Select-statement above. I therefore reasoned that I should be able to re-structure my problem and use the following select-statements instead:
    SELECT MAT_SALES
        FROM /BI0/PMAT_SALES
        INTO TABLE Z_FUNDGROUP
        WHERE
            MAT_SALES IN (
                SELECT DISTINCT MAT_SALES
                    FROM /BIC/AZBILCOPA00
            AND /BIC/ZACCASGRP IN ('a', 'b', 'c').
    but when I do this I still get errors. If I skip the "AND /BIC/ZACCASGRP IN ('a', 'b', 'c')" part it gives me valid results, but I have to be able to use this attribute. When I look at the master data table /BI0/PMAT_SALES in SE16 it shows me that there is a field named /BIC/ZACCASGRP and then I do not understand why I cannot use the above select.
    Best regards,
    Mikael

  • Help understanding WHERE statement.

    Hey you guys,
    I'm a complete newbie and have been studying Oracle SQL 11 Fundamentals book.
    On chapter 5 lab I ran into something I would like some explanation or clarification as of why is needed.
    Basically is asking to query the OE schema to find all employees whose birthdays occur between
    two days ago and seven days from now and based on that display some descriptive messages...
    select cust_first_name, cust_last_name, cust_email, date_of_birth,
    case to_number(to_char(date_of_birth, 'DD')) - to_number(to_char(sysdate, 'DD'))
      when -2 then 'Day before yesterday'
      when -1 then 'Yesterday'
      when  0 then 'Today'
      when  1 then 'Tomorrow'
      when  2 then 'Day after tomorrow'
      else 'Later this week'
    END BIRTHDAY
    from customers
    where to_char(date_of_birth, 'MON')= to_char(sysdate, 'MON')
    and to_number(to_char(date_of_birth, 'DD')) - to_number(to_char(sysdate, 'DD')) between -2 and 7
    order by to_char(date_of_birth, 'MMDD');
    I'm referring to the first condition in the where clause.
    Line 11 to_char(date_of_birth, 'MON')= to_char(sysdate, 'MON')
    Where I would like clarification is in the first clause of the where statement. Can someone explain why is needed?
    I feel like the second clause is enough to filter for the required task but when ran with just second where clause
    I get a different number of records.
    The first where clause compares that the birthday month of each employees is equal to the sysdate, how is that relevant?
    What if the current sysdate is 01-DEC-13 and some of the employees birthday is in Nov. How would that affect my result.
    Regards.

    I will assume person born Feb 29 celebrates birthday Feb 28 if current year isn't a leap year and Feb29 if it is a leap year. Then all we need to do is calculate birtday this year using ADD_MONTHS:
    with t as (
               select  cust_first_name,
                       cust_last_name,
                       date_of_birth,
                       add_months(date_of_birth,12 * (to_char(sysdate,'yyyy') - to_char(date_of_birth,'yyyy'))) date_of_birth_this_year
                 from  oe.customers
    SELECT  cust_first_name,
            cust_last_name,
            date_of_birth,
            case date_of_birth_this_year - trunc(sysdate)
              when -2 THEN 'Day before yesterday'
              when -1 THEN 'Yesterday'
              when  0 THEN 'Today'
              when  1 THEN 'Tomorrow'
              when  2 THEN 'Day after tomorrow'
              else 'In ' || (date_of_birth_this_year - trunc(sysdate)) || ' days'
            end birthday
      from  t
      where date_of_birth_this_year - trunc(sysdate) between -2 and 10
      order by date_of_birth_this_year - trunc(sysdate)
    CUST_FIRST_NAME      CUST_LAST_NAME       DATE_OF_B BIRTHDAY
    Danny                Wright               20-DEC-48 Day before yesterday
    Kiefer               Reynolds             21-DEC-53 Yesterday
    Maximilian           Henner               21-DEC-73 Yesterday
    Bo                   Ashby                21-DEC-56 Yesterday
    Shah Rukh            Field                25-DEC-57 In 3 days
    Rufus                Belushi              26-DEC-52 In 4 days
    Diane                Higgins              26-DEC-84 In 4 days
    Fritz                Hackman              26-DEC-83 In 4 days
    Danny                Rourke               31-DEC-47 In 9 days
    Grace                Dvrrie               31-DEC-48 In 9 days
    10 rows selected.
    SQL>
    And to mimic Feb 28 & 29 leap year:
    SQL> with t as (
      2             select  cust_first_name,
      3                     cust_last_name,
      4                     date_of_birth,
      5                     add_months(date_of_birth,12 * (to_char(date '2016-02-29','yyyy') - to_char(date_of_birth,'yyyy'))) date_of_birth_this_year
      6               from  oe.customers
      7            )
      8  SELECT  cust_first_name,
      9          cust_last_name,
    10          date_of_birth,
    11          case date_of_birth_this_year - trunc(date '2016-02-29')
    12            when -2 THEN 'Day before yesterday'
    13            when -1 THEN 'Yesterday'
    14            when  0 THEN 'Today'
    15            when  1 THEN 'Tomorrow'
    16            when  2 THEN 'Day after tomorrow'
    17            else 'In ' || (date_of_birth_this_year - trunc(date '2016-02-29')) || ' days'
    18          end birthday
    19    from  t
    20    where date_of_birth_this_year - trunc(date '2016-02-29') between -2 and 10
    21    order by date_of_birth_this_year - trunc(date '2016-02-29')
    22  /
    CUST_FIRST_NAME      CUST_LAST_NAME       DATE_OF_B BIRTHDAY
    Maureen              Sanders              29-FEB-24 Today
    Kris                 Curtis               02-MAR-55 Day after tomorrow
    Rob                  Russell              02-MAR-77 Day after tomorrow
    Harrison             Pacino               02-MAR-53 Day after tomorrow
    Keir                 Chandar              04-MAR-60 In 4 days
    Gerard               Hershey              06-MAR-48 In 6 days
    Sharmila             Fonda                06-MAR-49 In 6 days
    Luchino              Jordan               06-MAR-83 In 6 days
    Dom                  Hoskins              10-MAR-51 In 10 days
    Bruce                Hulce                10-MAR-72 In 10 days
    10 rows selected.
    SQL> with t as (
      2             select  cust_first_name,
      3                     cust_last_name,
      4                     date_of_birth,
      5                     add_months(date_of_birth,12 * (to_char(date '2016-02-28','yyyy') - to_char(date_of_birth,'yyyy'))) date_of_birth_this_year
      6               from  oe.customers
      7            )
      8  SELECT  cust_first_name,
      9          cust_last_name,
    10          date_of_birth,
    11          case date_of_birth_this_year - trunc(date '2016-02-28')
    12            when -2 THEN 'Day before yesterday'
    13            when -1 THEN 'Yesterday'
    14            when  0 THEN 'Today'
    15            when  1 THEN 'Tomorrow'
    16            when  2 THEN 'Day after tomorrow'
    17            else 'In ' || (date_of_birth_this_year - trunc(date '2016-02-28')) || ' days'
    18          end birthday
    19    from  t
    20    where date_of_birth_this_year - trunc(date '2016-02-28') between -2 and 10
    21    order by date_of_birth_this_year - trunc(date '2016-02-28')
    22  /
    CUST_FIRST_NAME      CUST_LAST_NAME       DATE_OF_B BIRTHDAY
    Maureen              Sanders              29-FEB-24 Tomorrow
    Rob                  Russell              02-MAR-77 In 3 days
    Harrison             Pacino               02-MAR-53 In 3 days
    Kris                 Curtis               02-MAR-55 In 3 days
    Keir                 Chandar              04-MAR-60 In 5 days
    Sharmila             Fonda                06-MAR-49 In 7 days
    Luchino              Jordan               06-MAR-83 In 7 days
    Gerard               Hershey              06-MAR-48 In 7 days
    8 rows selected.
    SQL>
    And to mimic Feb 28 non-leap year:
    SQL> with t as (
      2             select  cust_first_name,
      3                     cust_last_name,
      4                     date_of_birth,
      5                     add_months(date_of_birth,12 * (to_char(date '2014-02-28','yyyy') - to_char(date_of_birth,'yyyy'))) date_of_birth_this_year
      6               from  oe.customers
      7            )
      8  SELECT  cust_first_name,
      9          cust_last_name,
    10          date_of_birth,
    11          case date_of_birth_this_year - trunc(date '2014-02-28')
    12            when -2 THEN 'Day before yesterday'
    13            when -1 THEN 'Yesterday'
    14            when  0 THEN 'Today'
    15            when  1 THEN 'Tomorrow'
    16            when  2 THEN 'Day after tomorrow'
    17            else 'In ' || (date_of_birth_this_year - trunc(date '2014-02-28')) || ' days'
    18          end birthday
    19    from  t
    20    where date_of_birth_this_year - trunc(date '2014-02-28') between -2 and 10
    21    order by date_of_birth_this_year - trunc(date '2014-02-28')
    22  /
    CUST_FIRST_NAME      CUST_LAST_NAME       DATE_OF_B BIRTHDAY
    Maureen              Sanders              29-FEB-24 Today
    Kris                 Curtis               02-MAR-55 Day after tomorrow
    Rob                  Russell              02-MAR-77 Day after tomorrow
    Harrison             Pacino               02-MAR-53 Day after tomorrow
    Keir                 Chandar              04-MAR-60 In 4 days
    Gerard               Hershey              06-MAR-48 In 6 days
    Sharmila             Fonda                06-MAR-49 In 6 days
    Luchino              Jordan               06-MAR-83 In 6 days
    Dom                  Hoskins              10-MAR-51 In 10 days
    Bruce                Hulce                10-MAR-72 In 10 days
    10 rows selected.
    SQL>
    SY.

  • WHERE statement trouble

    I'm struggling with my WHERE statement below. I've bolded the couple of lines giving me trouble. Basically, I just need data returned when oh.ship_actual_date is null or it has a date equal to the sysdate. Any help would be much appreciated.
    select oh.order_number
          , oh.SHIP_ACTUAL_DATE
          , trunc(oh.order_date) as "Order Date"
          , trunc(oh.SHIP_UNTIL_DATE) as "Expected Ship"
          , oh.order_status
          , masterdata.getpicklisttext(:language_code, oh.order_status, 80) as order_status
          , masterdata.GetPickListText('E',Sales.Get_Order_Shipping_Status(oh.order_number),150) AS shipping_status
    from order_header oh , order_parts op
    where  oh.order_sub_type = 'LRS'
       and oh.order_number = op.order_number
       and oh.order_status not in( 'Q', 'V','C','M')
       and nvl(oh.drop_ship_only,'N') = 'N'
    *and oh.ship_actual_date = trunc(sysdate)*
        *OR oh.ship_actual_date is null*
    group by oh.order_number
         , oh.order_date
         , OH.SHIP_UNTIL_DATE
         , oh.ship_actual_date
         , oh.order_status
    order by OH.SHIP_UNTIL_DATE asc

    Hi,
    847497 wrote:
    *and oh.ship_actual_date = trunc(sysdate)*
    *OR oh.ship_actual_date is null*
    Don't mix AND and OR without using parentheses to make your meaning clear.
    AND (   oh.ship_actual_date  = TRUNC (SYSDATE)
        OR  oh.ship_actual_date  IS NULL
        )should do what you want, assuming oh.ship_actual_date is midnight. (And assuming you want what I think you want. When you don't post sample data, results and an explanation, people are just guessing.)
    If the hours, minutes and seconds of oh.ship_actual_date are not 00:00:00, then use something like:
    AND (   (    oh.ship_actual_date  >= TRUNC (SYSDATE) 
             AND  oh.ship_actual_date  <  TRUNC (SYSDATE) + 1
        OR  oh.ship_actual_date  IS NULL
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Simplify the problem as much as possible. If the only thing that you don't know how to do is the date comparison, post a problem that involves only the date comparison: no joins, very few columns.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}
    Edited by: Frank Kulash on Oct 2, 2012 12:57 PM
    You can get the right results using
    TRUNC (oh.ship_actual_date)  = TRUNC (SYSDATE)  but it will be inefficient. Why? Discuss.

  • Writing single query with conflicting WHERE statements

    How do I run the following as a single query that will result in a column that pertains to the first block of code and then another column that pertains to the 2nd block of code? The issue is that I need 2 different WHERE statements. So the final output will be patient_id, complete, incomplete.
    SELECT patient_id, COUNT(*) AS complete
    FROM STATUS
    WHERE status = 1
    GROUP BY patient_id
    ORDER BY patient_id;
    SELECT patient_id, COUNT(*) AS incomplete
    FROM STATUS
    WHERE status = 2
    GROUP BY patient_id
    ORDER BY patient_id;
    Thanks!

    Hi,
    apex wrote:
    Thanks for all of the help.
    I would like to add another column with decile and am struggling as to how to do it. Since I can't reference something in a calculation in the same step, I think I will need a 3rd nesting, but what I haven't figured out is how to get the number of subjects whose ratio is less than that subject's ratio. Right: you can't assign an alias (such as complete or ratio) to a calculated column and use that alias in the same sub-query.
    If the calculation isn't very complicated, then you might find it simpler just to repeat the calculation. For example, I think this is what you want:
    WITH     got_complete     AS
         SELECT    patient_id
         ,        COUNT ( CASE WHEN status = 1 THEN 1 END )     AS complete
         ,       COUNT ( CASE WHEN status = 2 THEN 1 END )      AS incomplete
         FROM        pt_status
         WHERE        status IN (1,2)
         GROUP BY  patient_id
    SELECT       patient_id, complete, incomplete
    ,                                complete / (complete + incomplete)     AS Ratio
    ,       RANK () OVER ( ORDER BY  complete / (complete + incomplete) ) - 1
                                                        AS decile
    FROM      got_complete
    ORDER BY  complete
    ,            incomplete     DESC
    ;RANK numbers rows 1, 2, 3, ... If I understand your requirements, you want the numbering to start with 0 (meaning "there are 0 other patients with a lower ratio"), so that's why I subtracted 1.
    Depending how you want to handle ties, you may need to add some tie-breaker expressions to the analytic ORDER BY clause, and/or use ROW_NUMBER instead of RANK.
    Here, I used the calculation "complete / (complete + incomplete)" in the ratio column, then repeated it in the decile column.
    I you want, you can add another sub-query, called got_ratio, which would add the ratio column, but do nothing about the decile column. Then, in the main query, you could use RANK as shown above (or, as you suggested, a scalar sub-query referencing got_ratio) to get the number of other pateient_ids with lower ratios.
    On the other hand, you could do this whole job without any sub-queries, using AVG as I did earlier, and then repeating that same AVG expression in the ORDER BY clause for RANK. Aggregate functions are computed before analytic fucntions, so the analytic RANK can referenece the aggregate AVG.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data. Include examples of decile ties (2 or more patients with the same ratio).
    Explain, using specific examples, how you get those results from that data.

  • Query WHERE statement to compare db record date

    Hello
    I can't get this where statement to work. I have it now so it is not throwing any errors, but it also isn't doing what it is supposed to.
    I am trying to match records date in my table with the actual calendar date, if there is a match, my cfif will take that match, and make it a link in the proper date. (it is a small calendar with the month, and the days of week with dates, each date will be normal, accept if there is a record for that date, it makes a link.
    This is my code, like I said, It doesn't throw an error, but it is not working either.
    My Query:
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate >= #CreateODBCDate("07/12/2005")# AND eventDate = #Days#
    </cfquery>
    This is the cfif statement:
    <cfoutput query="CaleventRec">
    <cfif Days EQ '#eventdate#'>
    <a href = "detail.cfm?id=#ID#">#Days#</a>
    </cfif>
    </cfoutput>
    this is all the code together:
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate >= #CreateODBCDate("07/12/2005")# AND eventDate = #Days#
    </cfquery>
                            <!--- Set the ThisDay variable to 0. This value will remain 0 until the day of the week on which the first day of the month falls on is reached. --->
                            <cfset ThisDay = 0>
                            <!--- Loop through until the number of days in the month is reached. --->
                            <cfloop condition = "ThisDay LTE Days">
                                <tr>
                                <!--- Loop though each day of the week. --->
                                <cfloop from = "1" to = "7" index = "LoopDay">
                                <!--- This turns each day into a hyperlink if it is a current or future date --->
                                   <cfoutput query="CaleventRec">
              <cfif Days EQ '#eventdate#'>
                                   <a href = "detail.cfm?id=#ID#">#Days#</a>
                                   </cfif>
              </cfoutput>
                                <!---
                                    If ThisDay is still 0, check to see if the current day of the week in the loop matches the day of the week for the first day of the month.
                                    If the values match, set ThisDay to 1.
                                    Otherwise, the value will remain 0 until the correct day of the week is found.
                                --->
                                    <cfif ThisDay IS 0>
                                        <cfif DayOfWeek(ThisMonthYear) IS LoopDay>
                                            <cfset ThisDay = 1>
                                        </cfif>
                                    </cfif>
                                <!---
                                    If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay
                                    the day of the mnth and increment the value.
                                --->
                                        <cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
                                        <cfoutput>
                                        <!--- I choose to highlight the current day of the year using an IF-ELSE. --->
                                            <cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
                                                <td align = "center" bgcolor="##FFFF99">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                                                    <font class = "calendartoday">#ThisDay#</font>
                                                </td>
                                            <cfelse>
                                                <td align = "center">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                                                    <font class = "calendar">#ThisDay#</font>
                                                </td>
                                            </cfif>
                                        </cfoutput>
                                        <cfset ThisDay = ThisDay + 1>
                                        <cfelse>
                                            <td></td>
                                    </cfif>
                                </cfloop>
                                </tr>
                        </cfloop>
    I know my where statement is incorrect, I am also not sure if my cfif statement is correct either. Can anyone help me figure this out?
    thank you!
    CFmonger

    All the rest of the code works. The only part of this that doesn't work is the trying to make a link part.
    Let me  show you where I am, and what I did, then maybe you will see I am closer to the solution... I think. I made this calendar so you can cycle through the months. So if you are looking at June, you see Sun - Sat and the dates for each day of the week in the month of june. You can then choose to click the next button that will bring up the month of july, and you can keep on going as long as you want.
    That is one function and it working as of right now. This Calendar also shows what day of the week we are on. If it is June 16th then June 16 is yellow. This also works.NOw, what I need to do it to have my query, not only filter out the records for the month, (if we are in June, then the Query separates out the records for June, the date in my DB is set to mm/dd/yyyy) This query also needs to match it to a number, the days of the month. So, if there is a record on the 25th of June, then the 25th of June will be a link to another page using it's ID in the address line. If you go to July and there are lets say 3 records for that month, then all 3 dates will become a link to the same other page using it's ID in the url.
    This is what I have now. I tied the Query into the next / prev function so it filters the month, so far it seems to work, I can do a cfdump up to the point of my cfif statement and get the proper number from the date, my cfif is not firing so If I do a dump after it, it doesn't dump anyhting.
    I will post JUST the query code, then post the whole calander code so you can see it all together.
    The Query / link code:
    <!--- This is part of the next / prev nav to cycle through the months --->
    <cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
    <cfset NextMonth = DatePart('m', NextMonthYear)>
    <!--- My Query --->
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate Between #NextMonthYear# and #NextMonth#
    </cfquery>
    <!--- my output / cfif stement --->
    <cfoutput query="CaleventRec">
    <cfset comparison = DateCompare('#dateFormat(eventDate, 'dd')#', '#Days#', 'd')>
    <!--- When I do a cfdump here, I get the number of the first record with a day date in the DB for the month of june
    <cfdump var="#dateFormat(eventDate, 'dd')#">
                                   <cfabort>--->
    <cfif #Days# EQ ('#dateFormat(eventDate, 'dd')#')>
    <!--- When I do a dump here, I do not get anyhting, no numbers it doesn't fire
    <cfdump var="#eventDate#">
    <cfabort>--->
    <a href = "detail.cfm?id=#ID#">#Days#</a>
    </cfif>
    </cfoutput>
    ok, now that is the part to stream in the DB info into the calander.
    Here is all the code, like I said, it all works, just not making each day a link that has a record in the DB.
    <!--- Declaration of the variables --->
           <cfparam name = "month" default = "#DatePart('m', Now())#">
    <cfparam name = "year" default = "#DatePart('yyyy', Now())#">
    <cfparam name = "currentday" default = "#DatePart('d', Now())#">
    <cfparam name = "startmonth" default = "#DatePart('m', Now())#">
    <cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">
    <!--- Set a requested (or current) month/year date and determine the number of days in the month. --->
    <cfset ThisMonthYear = CreateDate(year, month, '1')>
    <cfset Days = DaysInMonth(ThisMonthYear)>
    <!--- Set the values for the previous and next months for the back/next links.--->
    <cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
    <cfset LastMonth = DatePart('m', LastMonthYear)>
    <cfset LastYear = DatePart('yyyy', LastMonthYear)>
    <cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
    <cfset NextMonth = DatePart('m', NextMonthYear)>
    <cfset NextYear = DatePart('yyyy', NextMonthYear)>
    <cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
    <cfset CurrentYear = DatePart('yyyy', Now())>
    <table border="0" width="100%" bgcolor ="#ffffff">
                <tr>
                    <td align = "center" valign="top">
                        <table border="0" width="100%" height="100%">
       <tr>
          <th align="center" colspan="7" bgcolor="#2b4e6e">
       <cfoutput>
       <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="15%" align="left" valign="middle">
      <cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)>
    <cfelse>
      <a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
            <td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
            <td width="13%" align="right" valign="middle">
      <cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)>
    <cfelse>
    <a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a>  </cfif></td>
          </tr>
        </table></cfoutput></th>
       </tr>
       <tr>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
        <td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>
       </tr>
    <cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
    SELECT events.eventDate, events.ID AS ID
    FROM events
    WHERE eventDate Between #NextMonthYear# and #NextMonth#
    </cfquery>
                            <!--- Set the ThisDay variable to 0. This value will remain 0 until the day of the week on which the first day of the month falls on is reached. --->
                            <cfset ThisDay = 0>
                            <!--- Loop through until the number of days in the month is reached. --->
                            <cfloop condition = "ThisDay LTE Days">
                                <tr>
                                <!--- Loop though each day of the week. --->
                                <cfloop from = "1" to = "7" index = "LoopDay">
                                <!--- This turns each day into a hyperlink if it is a current or future date --->
             <cfoutput query="CaleventRec">
             <cfset comparison = DateCompare('#dateFormat(eventDate, 'dd')#', '#Days#', 'd')>
              <cfdump var="#dateFormat(eventDate, 'dd')#">
                                   <cfabort>
              <cfif #Days# EQ ('#dateFormat(eventDate, 'dd')#')>
              <cfdump var="#eventDate#">
                                   <cfabort>
                                   <a href = "detail.cfm?id=#ID#">#Days#</a>
                                   </cfif>
              </cfoutput>
                                <!---
                                    If ThisDay is still 0, check to see if the current day of the week in the loop matches the day of the week for the first day of the month.
                                    If the values match, set ThisDay to 1.
                                    Otherwise, the value will remain 0 until the correct day of the week is found.
                                --->
                                    <cfif ThisDay IS 0>
                                        <cfif DayOfWeek(ThisMonthYear) IS LoopDay>
                                            <cfset ThisDay = 1>
                                        </cfif>
                                    </cfif>
                                <!---
                                    If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay
                                    the day of the mnth and increment the value.
                                --->
                                        <cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
                                        <cfoutput>
                                        <!--- I choose to highlight the current day of the year using an IF-ELSE. --->
                                            <cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
                                                <td align = "center" bgcolor="##FFFF99">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendartoday">#ThisDay#</font>
                                                </td>
                                            <cfelse>
                                                <td align = "center">
                                                    <cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
                <font class = "calendar">#ThisDay#</font>
                                                </td>
                                            </cfif>
                                        </cfoutput>
                                        <cfset ThisDay = ThisDay + 1>
                                        <cfelse>
                                            <td></td>
                                    </cfif>
                                </cfloop>
                                </tr>
                        </cfloop>
                        </table>
                    </td>
                </tr>
            </table>
    It is kind of complicated and this is why I need help. Maybe I am wrong in the variables I am pulling, but like I say in my comments, so far I pulled the day part of the month I am in out of the records up until my cfif stement.Can this be done with what I have done so far? No need to rewrite the whole calander, just the part with the query if I miss what you are saying.

  • Filter data using where statement : need to filter a variable if it starts

    Hi,
    in my loop statment , i am using a where condition.
    a variable has numbers and characters , i want to filter the variable using where statement identifying if it is acharacter not to enter into the loop.
    any suggestions . Thanks in advance.
    regards,
    Ry

    Hi ,
    try like this
    data:l_file_data(20) type c,
    oref   TYPE REF TO cx_root.
    data: l_amount type p decimals 2.
    l_file_data = '12A3'.
    try.
    l_amount = l_file_data.
    catch cx_root into oref.
    endtry.
    if oref is not initial.
    write: 'Miss Match'.
    endif.
    regards
    Prabhu

Maybe you are looking for

  • Window 8.1 device mdm enrolment issue

    Window 8.1 device(Laptop and Tablet) doesn't shows the option of entering enrollment server address while enrolling it through Network->Workplace Settings. Windows Phone 8.1 doesn't have this issue. 

  • IMovies4 - B&W - Stupid new user question

    I'm trying to copy old home movies from an analogue vdeo camera to iMovies. No matter what I do it comes out in B&W even though the source is in colour. What am I doing wrong??

  • MIGO to receive by PO or Inbound delivery number?

    HI, I've created a Inbound delivery with 2 line item for a PO. Then do MIGO receipt by Inbound delivery number. In MIGO screen, only 1 line item display. It supposed 2 line item (inbound contain 2 line item). So far, I havn't receipt any for this PO.

  • Z97 Gaming 7 won't post. debug LEDs at 41-43. MSI LED is off.

    Hi everyone, Doing my first build in quite a few years so somewhat of a Noob. I'm using an MSI Gaming 7 and an Intel 4970k. I'm using 2x4GB Crucial 1833 SDRAM. After hooking CPU and MB, and cooler (Evo 212) I decided to see if things boot before inst

  • System Error in program CL_RSR_CHABIT and form SET_BIT 1-02-(See Long Text)

    Dear Experts, Recently, when I execute my intergrated planning query, I had the above error. I have searched the whole SDN for solution and I found many threads and solutions. I have tried all the solutions and still I have the error even after all o