Updating a variable based on checking expiration date against now() in each row of a table

I’m using Coldfusion 9,0,0,251028 on Windows 7 64-bit, with a Microsoft Access 97 database.
I’m trying to create a query which loops through all the rows in a table and checks if the current date is later or earlier than the expiration date. 
If the expiration date column is earlier than now(), it sets the column “is_current” to 0, which is a variable that controls whether or not a message displays on a different page(breakingnews.cfm). 
The column that has the expiration date is “exp_dat” in the table “news”. The query I have so far is:
<cfquery name="expire" datasource="#db#">
update news
set is_current = 0
where exp_dat < now()
</cfquery>
What this ends up doing is filtering out the expired items correctly, but once a new row is inserted, the previous items(which haven’t expired yet)
are still having the “is_current” column set to 0.
The query is cfincluded on the page the messages are supposed to display on (breakingnews.cfm). 
How can I get the query to loop over each row every time to check if the now() is earlier or later than “exp_dat” without setting all the other row’s “is_current” to 0?

Two things:
1 - A query will never affect rows you haven't told it to. Therefore if new rows have the is_current set to 0, then it's because you're either setting it so in your insert statement or you've set a default value on the column. Just make sure you set the column to 1 when you insert the new row.
2 - Why are you doing this at all? Say you run your update query (which is relatively intensive) a millisecond before one expires, it'll still be shown on your page. Why are you not just doing "SELECT * FROM mytable WHERE expiration_date > now()"?
Obviously use cfqueryparams, but that's just an example. It seems at the moment all you're doing is storing out-of-date data in a database and causing yourself a lot more work and overhead.

Similar Messages

  • I was informed my credit card expired in February but was not informed until March. I logged in and updated the new expiration date but now Netflix has cancelled my subscribtion. What can I do?

    Was informed by Itunes that my credit card expired in February but was not informed until March. I logged in and put new expiration date but now Netflix has cancelled my subscription. What's up with this?

    Contact Netflix and ask them.
    Contact iTunes customer support and ask them.
    Why would you think anyone in these user to user support forums would be able to assist in this matter?

  • How to identify date & time of insertion of rows in a table

    Hi,
    Is it possible to identify the date & time of insertion of rows in a table?
    for example:
    Table name: emp
    I have rows like this
    emp_code name dept
    pr01 ram edp
    ac05 gowri civil
    pr02 sam pro
    i want to know the date and time of the insertion this( ac05 gowri civil).
    Could you please help me.....
    Thanks in advance....

    psram wrote:
    sorry for the confusion. I dont want to store date and time. I said that for example only.
    I have table which consists of thousands of rows. I want to know the insertion date & time of a particular row.
    Is it possible?So, if I have a table that stores a load of employee numbers, do you think I could get the database to tell me their names?
    If you don't store the information, you can't query the information.
    Ok, there are some dribbs and drabbs of information available from the back end of the database via the SCN's, Archive Logs etc., but those sort of things disappear or get overwritten as time goes by. The only way to know the information it to ensure you store it in the first place.
    So, in answer to your question, No, there isn't a true and reliable way to get the data/time that rows were inserted into the table, unless you have chosen to store it alongside the data.

  • Alert based on Batch Expiration Date

    Scenario:
    Batch Managed Items
    Type: for every transaction
    Goods receipt PO >  Batch setup window > "Expiration date" ( activate expiration date field from form settings)  > set date
    Requirement:
    An alert to be sent to the purchase dept. user 10 days prior to the defined "expiration date"  (in the batch setup window)
    vijay
    Edited by: SU Vijay on Oct 6, 2008 3:42 PM

    Use this query
    SELECT T0.[ItemCode], T0.[ItemName],T0.[BatchNum], T0.[WhsCode],
    T0.[ExpDate],datediff(dd,getdate(),T0.[ExpDate]) as 'Days to Expire'
    FROM OIBT T0  where datediff(dd,getdate(),T0.[ExpDate]) =10

  • How to update vendor address based on vendor control data

    Hello,
    i have a request to update one field (Search term 2) from Vendor master Address view:
    based on industry code populated for the supplier (LFA1-BRSCH):
    This means if industry code is populated, address field SORT2 must be updated with corresponding wording for this code.
    How is it possible to do this?
    I cannot use BAdI definition name ADDRESS_UPDATE as ADDRESS1_SAVED method is triggered only if one address field is modified.
    I found VENDOR_ADD_DATA enhancement spot with VENDOR_ADD_DATA BAdI definition: can i use SAVE_DATA method?
    If yes, which function module can i use to update LFA1 table? Is it OK with CHANGEDOCUMENT_SINGLE_CASE?
    Thank you for your help.
    Regards.
    Laurent.

    Hello Sreejith,
    thank you for the user-exit you gave me: it works as required.
    Here is ABAP code:
    CONSTANTS: lc_abap_true TYPE xfeld VALUE 'X',
               lc_lfa1      TYPE ad_ownertp VALUE 'LFA1'.
    DATA: lt_id_list TYPE TABLE OF bupa_partner,
          lt_lfa1    TYPE TABLE OF lfa1,
          lt_adrc    TYPE TABLE OF adrc,
          ls_lfa1    TYPE lfa1,
          ls_adrc    TYPE adrc,
          ls_address_selection TYPE addr1_sel,
          ls_addr1_val TYPE addr1_val,
          ls_addr    TYPE bapiad1vl,
          lt_addr    TYPE TABLE OF bapiad1vl,
          ls_addrx   TYPE bapiad1vlx,
          lt_addrx   TYPE TABLE OF bapiad1vlx,
          lt_return  TYPE isi_bapiret2_tt.
    DATA: lv_brsch_txt TYPE text1_016t,
          lv_objid TYPE ad_objkey.
    APPEND i_lfa1-lifnr TO lt_id_list.
    CALL FUNCTION 'BBP_VENDOR_GET_DATA2'
      EXPORTING
        wo_purch_org = lc_abap_true
      TABLES
        itab_id_list = lt_id_list
        itab_lfa1    = lt_lfa1
        itab_adrc    = lt_adrc.
    READ TABLE lt_lfa1 INTO ls_lfa1 INDEX 1.
    READ TABLE lt_adrc INTO ls_adrc INDEX 1.
    MOVE ls_adrc-addrnumber TO ls_address_selection-addrnumber.
    CALL FUNCTION 'ADDR_GET'
      EXPORTING
        address_selection = ls_address_selection
      IMPORTING
        address_value     = ls_addr1_val
      EXCEPTIONS
        parameter_error   = 01
        address_not_exist = 02
        version_not_exist = 03
        internal_error    = 04
        OTHERS            = 99.
    IF sy-subrc EQ 0.
      IF NOT i_lfa1-brsch IS INITIAL OR NOT ls_lfa1-brsch IS INITIAL.
        SELECT SINGLE brtxt
         INTO lv_brsch_txt
         FROM t016t
         WHERE spras = sy-langu
         AND   brsch = i_lfa1-brsch.
        IF ( ls_lfa1-brsch NE i_lfa1-brsch OR ls_adrc-sort2 NE ls_addr1_val-sort2 ).
          CLEAR : lv_objid.
          MOVE i_lfa1-lifnr TO lv_objid.
          MOVE lv_brsch_txt TO ls_addr-sort2.
          APPEND ls_addr TO lt_addr.
          MOVE 'X' TO ls_addrx-sort2.
          APPEND ls_addrx TO lt_addrx.
          CALL FUNCTION 'BAPI_ADDRESSORG_CHANGE'
            EXPORTING
              obj_type    = lc_lfa1
              obj_id      = lv_objid
            TABLES
              bapiad1vl   = lt_addr
              bapiad1vl_x = lt_addrx
              return      = lt_return.
        ENDIF.
      ENDIF.
    ENDIF.    "sy-subrc
    Regards.
    Laurent.

  • How do I , rented videos that were deleted during these recent updates and before their 30 day expiration date?

    How do I reload unviewed videos that were deleted during these latest updates prior to their 30 day rental period?

    You cannot download them again, but if you contact iTunes, they may be able to reset them for you or let you download them again since the movies disappeared during the update. They have been know to do this for other users in the past.
    Give it a shot here.
    http://www.apple.com/support/itunes/contact/

  • Authority-Checks: Matching data against authorities or profiles

    Hello all,
       I like to match values at runtime against authorities or profiles. But I can't find any function-module or class to perform that.
    The idea is, to check values for authority-checks to a profile (authority) or role without having a certain user.
    The only thing I want to know is: Would the current fields/values fulfill a authority given by a known profile or role.
    Can anyone help me?
    Thanks a lot in advance.
    Elmar

    The Point is, that we have to check authorities of Users of a web-application which are Web-Users but not SAP-Users.
    The idea was to check authorities via the SAP-authority system. That is, why it is necessary to check a 'Web-user-profile' against current values sent by the web-application. If it is no possible to perform a authority-check w/o a certain user, I will be forced to implement my own authority-check. This is also possible, but that makes a big effort.

  • Condtion based xml for each row of the table t-sql

    Hello ,
    i have below data.
    create table #students
    id int identity(1,1) primary key,
    student_id int not null,
    [s_m_cml] xml
    insert into #students
    student_id,
    [s_m_xml]
    values
    101,
    '<submarks><submark><subject>Arts</subject><marks>85</marks></submark><submark><subject>Science</subject><marks>95</marks></submark><submark><subject>maths</subject><marks>100</marks></submark></submarks>'
    ),(102,'<submarks><submark><subject>Arts</subject><marks>50</marks></submark><submark><subject>Science</subject><marks>75</marks></submark><submark><subject>maths</subject><marks>85</marks></submark></submarks>')
    select * from #students
    if all subjects- marks in s_m_xml marks > 80 then i select the row as promoted else as demoted. the exact output should look like below.
    student_id [status]
    101 promoted
    102 demoted
    what is the best way to achieve this using t-sql. Thanks in advance for any suggestions.

    You dont need to parse out the values from xml for this
    You can do the check inline
    see illustration below
    drop table #students
    create table #students
    id int identity(1,1) primary key,
    student_id int not null,
    [s_m_cml] xml
    insert into #students
    student_id,
    [s_m_cml]
    values
    101,
    '<submarks><submark><subject>Arts</subject><marks>85</marks></submark><submark><subject>Science</subject><marks>95</marks></submark><submark><subject>maths</subject><marks>100</marks></submark></submarks>'
    ),(102,'<submarks><submark><subject>Arts</subject><marks>50</marks></submark><submark><subject>Science</subject><marks>75</marks></submark><submark><subject>maths</subject><marks>85</marks></submark></submarks>')
    ,(104,'<submarks><submark><subject>Arts</subject><marks>92</marks></submark><submark><subject>Science</subject><marks>88</marks></submark><submark><subject>maths</subject><marks>98</marks></submark></submarks>')
    select *,
    case when [s_m_cml].exist('/submarks/submark[data(marks) < 80]')=1 then 'demoted' else 'promoted' end as status
    from #students
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Please::Getting Data Through Setting Focus On Row in ADFReadOnly Table ? ??

    Hi All ;
    By clicking on tableSelectOne on Row in ADFReadOnly I can Get All of the rest of the Row Data in inputtexts ;
    I want To Do The Same Action not By clicking on tableSelectOne but by clicking on any Cell On This Row , Can any body help by example ??
    Regards;

    Abu,
    here's a website full of such hints
    http://www.oracle.com/technology/jsf/index.html
    your usecase is
    http://vgoldin.blogspot.com/2007/01/Weing-aftableselectone-by-clicking.html
    Frank

  • Update a column in each row in my table that have similar values in another column

    Hi All,
    I have a table in my DB.
    This table has values like this:
    Name
    Key
    a
    1
    a
    2
    a
    3
    a
    2
    b
    4
    b
    5
    b
    5
    I need to change the name to a different name for keys that are different. For same keys, the name must be same.
    Here I need to rename the 'a' to different name, but make sure that the 'a' that have 2 as the key have same name .
    Similarly, i've to rename the 'b' to different name , but make sure that the 'b' that have 5 as the key have the same name.
    How can I achieve this in sql? I dont know how to use cursor and complex queries, as i'm new to SQL.
    Please help
    Thanks,
    Vid
    Vidya Suryanarayana

    Ok. The output should be like this:
    Note here, that the names with same keys have same names.
    name
    key
    a1
    1
    a2
    2
    a3
    3
    a2
    2
    b1
    4
    b2
    5
    b2
    5
    Thanks,
    Vid
    Vidya Suryanarayana

  • Vb6 Expiring Date

    please am doing my project and i need some help in vb6
    i need sql statement that will list all product that will expire within 60days based on their expiring date.
    this is my code, kindl help me
    Adodc6.RecordSource = "Select * from tblproduct where Expdate <= '" & Now.AddMonths(3) & "'"
     thank you
    Thanks In Advan

    Hi,
    Since this is a Visio forum, if you want to receive more information about SQL code, I recommend you post this problem in SQL forum.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Regards,
    Greta Ge
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • How to create a new table based out of old data rows

    Hi All,
    How to create a new table based out of old data rows. Also how can we find out the DBF for different users in a database?
    Saqib

    Not very clear what you need. I'll try to interpret...
    How to create a new table based out of old data rowsIf this means how to create a table from an existing one, then you can do :
    SQL> create table <new table> as select * from <old table>;
    if you need a subset of rows you can add a where clause.
    how can we find out the DBF for different users in a database?Here I need some more clarification. What do you mean exactly ?

  • Updating the recoed based on the value of check box

    I have a form which has a check box for each record.
    I want to update the values of the checked records.
    Enclosing my code below:
    htp.htmlOpen;
    htp.headOpen;
    htp.title ('Out Details Form');
    htp.headClose;
    htp.bodyOpen;
    htp.header (1,'Out Details Form');
    htp.formOpen ('RSA.UPDATE_OUT_RECORDS');
    br_code := substr(PORTAL.wwctx_api.get_user(),1,2);
    product_code := upper(p_product_code);
    for each_rec IN ref_cursor (p_date,br_code,product_code)
    loop
    htp.p(each_rec.ref_no);
    htp.p(each_rec.name);
    htp.p('<input type = "hidden" name ="p_ref_no" value = '||each_rec.ref_no||'>');
    htp.p ('<input type = "checkbox" name = "p_cd" >');
    htp.p ('<br>');
    end loop;
    htp.p('<br>');
    htp.p ('Courier Name');
    htp.p('<input type = "text" name ="p_courier">');
    htp.p('Courier Number');
    htp.p('<input type = "text" name ="p_courier_no">');
    htp.p('Destination Branch Code');
    htp.p ('<input type = "text" name ="p_branch">');
    htp.p('<br>');
    htp.formSubmit ('Submit');
    htp.bodyClose;
    htp.htmlClose;
    end;
    my update procedure is given below
    Create or Replace PROCEDURE RSA.UPDATE_OUT_RECORDS
    p_ref_no IN PORTAL.wwv_utl_api_types.vc_arr,
    p_cd IN PORTAL.wwv_utl_api_types.vc_arr,
    p_courier IN VARCHAR2,
    p_courier_no IN VARCHAR2,
    p_branch IN VARCHAR2,
    submit IN VARCHAR2
    as
    begin
    for i in 1..p_ref_no.count loop
    htp.p(p_ref_no(i));
    update RS_MIMO_TRANSACTIONS
    set RS_MIMO_TRANSACTION_TO_PLACE = p_branch,
    RS_MIMO_TRANSACTION_OUT_TIME = sysdate,
    RS_MIMO_TRANSACTION_COURIER_NO = p_courier_no,
    RS_MIMO_TRANSACTION_COUR_NAME = p_courier
    where RS_MIMO_TRANSACTION_REF_NO = p_ref_no(i);
    commit;
    end loop;
    exception
    when others then
    null;
    end;
    When I ran the above all the records are getting updated
    even if I have not clicked the check box.
    Please help me how to check the value of the checkbox in the UPDATE_OUT_RECORDS procedure and updating those records for which the check box is clicked.

    You can declare one more dummy variable in your procedure to be used as checkbox field in your form and with some javascript code you can set the value 'Y'(es) or 'N'(o) in the original variable which you can refer it in your update procedure to update values in the table. Here is the sample code how you can do this:
    declare
    lv_string varchar2(32767);
    li_ind integer;
    begin
    lv_string := '<SCRIPT LANGUAGE="JavaScript">
         function set_chkbx_value(row_num){
         SampleForm.p_yes_no[row_num].value = (SampleForm.p_dummy_chkbx[row_num].checked)?"Y":"N";
    </SCRIPT>';
    lv_string := lv_string ||'<BODY>
              <CENTER>
              <form name=SampleForm action="p_update_table" METHOD="POST" ENCTYPE="multipart/form-data">
              <div align="center">
                   <center><TABLE>
                   <TD align="center"><TABLE BORDER="1" CELLSPACING="2" CELLPADDING="0">
                   <BR><TR>
                   <TH><b><font STYLE="font-family:Tahoma; color:brown; font-size:9pt;">Name</font></b></TH>
                   <TH><b><font STYLE="font-family:Tahoma; color:brown; font-size:9pt;">Salary</font></b></TH></TR><TR>';
         For li_ind in 1..10 Loop     
         lv_string := lv_string ||'<TR><TD ALIGN=middle><INPUT TYPE=text SIZE="20" NAME="p_name" MAXLENGTH = "30" >
                             <INPUT TYPE=text SIZE="10" NAME="p_salary" MAXLENGTH = "30" >
                             <TD ALIGN=middle><INPUT TYPE=checkbox SIZE="1" NAME="p_dummy_chkbx" OnClick="set_chkbx_value('||(li_ind - 1)||')"></TD>
                             <INPUT TYPE="hidden" NAME="p_yes_no"></TR>';
         End Loop;
         lv_string := lv_string ||' </TABLE></CENTER>
              <h2 align="center">
              <INPUT TYPE="Submit" VALUE="SAVE">
              <input type="reset" value="RESET"><h2>
              </TABLE>
              </FORM>
              </BODY>';
    htp.p(lv_string);
    end;
    Create or Replace PROCEDURE p_update_table
    p_name IN PORTAL.wwv_utl_api_types.vc_arr,
    p_salary IN PORTAL.wwv_utl_api_types.vc_arr,
    p_dummy_chkbx IN PORTAL.wwv_utl_api_types.vc_arr,
    p_yes_no IN PORTAL.wwv_utl_api_types.vc_arr
    as
    begin
    for i in 1..p_name.count loop
    If p_yes_no(i) = 'Y' Then
    update emp
    set sal = p_salary(i)
    where ename = p_name(i);
    commit;
    end loop;
    exception
    when others then
    null;
    end;

  • How to update cc expire date

    How do I update the expire date of my credit card?

    Hi and welcome to the Skype Community,
    Please sign in to your Skype web account page at www.skype.com/go/myaccount
    Open your "Billing information" section and then check your "stored payment details". You can add your updated CC information as new payment details there. Once you've added the updated CC details as new payment method you can cange your payment method for a recurring subscription to that one.
    Follow the latest Skype Community News
    ↓ Did my reply answer your question? Accept it as a solution to help others, Thanks. ↓

  • Document Expiration Date Not Updating

    Hi,
    I’ve implemented a document retention policy based upon a custom date field. The custom date field is not for users to edit so it defaults to 1/1/1900 for new documents and I have written a console app that updates the custom date field to an appropriate
    date. The problem is that the expiration date, both for new and existing documents, doesn’t update. This is also the case if I update the document properties manually. In dev updating the custom date field, manually or via code,
     triggers an update in the expiration date but this isn’t happening in UAT. We’re using a content type hub in UAT although I can’t see how that makes a difference as the information management policies have been distributed correctly.
    Does anyone have an ideas as to why the expiration dates are not re-calculating?
    Thanks in advance
    Neil

    It is running and I've run it manually a number of times. But my understanding is that the job only updates new or amended expiration policies, it doesn't re-calculate for existing ones. That aside, the expiration date should update immediately when
    the field upon which is based is updated - at least that's the behaviour I've seen in development.

Maybe you are looking for

  • App with hadwriting notes for .pdf and .doc files?

    Is there and app that aloud to makes HANDWRITING NOTES (with Stylus, using different colours, sizes, etc) in files .pdf or .doc??? I really need something like Paperpad App, to make notes while reading. Thank you.

  • How to get the node value of payload

    Hi The null is returned when I use the following code to get the User_ID element in the payload, but there are values in the User_ID element of the payload Task task_test = wfSvcClient.getTaskQueryService().getTaskDetailsById(wfCtx, taskId); System.o

  • Xfce4-notifyd themes [solved]

    I was wondering if anyone knew how to change the theme/look of notifyd, or at least a place to start looking. The most I could find was a faq saying it inheirits it's appearance from the current GTK theme, but that doesn't seem to be correct... The d

  • Playing simultaneous animations when clicking on a button

    Hello, Does anyone knows how to make two animations on the timeline in edge animate play simultaneously when i click on a button ? I have a button in my menu, when i click on it i need to play to animations from the timeline. Thanks for helping me.

  • Trying to deploy axisproviderlib.sda

    When I try to deploy axisproviderlib.sda, i get an unresolved dependency on com.sap.base.technology.facade and engine.j2ee14.facade.    Where can i find them?  I have had no luck.