Use a CFC to update a database with a date

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Use a CFC to update a database with a date

    Hi All, I am trying to input a date in a database field with the current date.
    The datefield is in one table and I only want the date to be inserted if the ID
    fields are equal to each other between the two tables. Can I put two
    different queries in one cffunction?? The first query would query the first
    table for the tbl ID. The second query would do the update based on the where
    clause (where tbl1ID = tbl2ID). Am I way of track with this one. If I didn't
    make it clear please let me know.

    Thanks in advance

    Maurice

    EdmondsM Guest

  2. Similar Questions and Discussions

    1. mySQL Update Date
      i want to update the time portion of a date column without knowing or change the actually day. so if the list of dates were xDate 2006-01-12...
    2. Date() in SQL database
      In Access I can set a default value in a date field by using Date(). How do I do this in an SQL Server database. Bill
    3. Update Access with today's date
      I am creating a form to allow the user to enter new records to an Access database. I want to have a hidden field that enters the date of record...
    4. converting date into database date format(newbie)
      Hi! U can convert "8-Aug-03" into mysql date which requires yyyy-mm-dd format as below. <?php date("Y-m-d",strtotime("8-Aug-03")); ?>
    5. Date update?
      Does anyone know how to have the date on your home page update automatically? I can't find any code. Thanks in advance! --Nathan
  3. #2

    Default Re: Use a CFC to update a database with a date

    I can't see any reason why you could not do this, but there is no need. This
    can be done in the single query

    With one query
    Update Table2
    Set dateColumn = #Now()#
    Where idColumn IN (Select idColumn From Table1)


    To do it with 2 queries

    <cfquery name="qry_getIds" datasource="DSN">
    Select idColumn From Table1
    </cfquery>
    <cfset returnedIDS = ValueList(qry_getIds.idColumn)>
    <cfquery name="qry_Update" datasource="DSN">
    Update Table2
    Set dateColumn = #Now()#
    Where idColumn IN (#returnedIDS#)
    </cfquery>


    Ken

    The ScareCrow Guest

  4. #3

    Default Re: Use a CFC to update a database with a date

    Hi Ken, this does add the date to datefield in the db. But the problem that I am having is more than the record is being updated. I just want the record where both ID are equal.

    Thanks


    EdmondsM Guest

  5. #4

    Default Re: Use a CFC to update a database with a date

    You will need to post your code and the logic of what you want to achieve. If
    you have a list of id numbers the query will only update where those numbers
    are equal.

    So in the example I gave it selects all the records from table1, so you may
    need to filter the records from table one.

    Ken

    The ScareCrow Guest

  6. #5

    Default Re: Use a CFC to update a database with a date

    Hi Ken, the code that I have is pretty much what you gave me. Yes, I am going
    to have to filter the records based on the url value or hidden field. Can you
    pass something like #url.variable# or #form.variable# to a CFC??

    EdmondsM Guest

  7. #6

    Default Re: Use a CFC to update a database with a date

    You need to use something like the following example
    <cfargument name="myName" required="true" type="string" displayname="myName">
    in component's method
    as well as WHERE MyColumn_Name = '#myName#' in query
    and
    <cfinvokeargument name="myName" value="#url.urlname#"> (or <cfinvokeargument
    name="myName" value="#form.formname#">) - in calling page.

    CF_Oracle Guest

  8. #7

    Default Re: Use a CFC to update a database with a date

    Hey Ken, I finally got this to work. I ended up using a hidden field to pass the values that I wanted.

    Thanks for your help

    EdmondsM Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139