DW
|
Posted: 01/07/2004, 8:40 AM |
|
I would like to update a date field in a table that has a lastupdated field for each table in the database with the current date each time a user makes a change or addition to that table for a particular primary key.
So if a user adds another entry or changes an entry in the "cars" table for owner "Fred Jones", then another table called "lastupdated", which has a "Fred Jones" record has the field "lastupdated_cars" updated with todays date.
Any hints or direction on doing this?
Thanks,
DW
|
|
|
Bon733
|
Posted: 01/07/2004, 10:06 AM |
|
I had the same question some time back and it was answered in the newsgroup.
You might want to check the past newsgroup discussions (if they are still
available). Sorry I don't have an exact date of the discussion but I will
look through my notes tonight and let you know if I find something.
BON
"DW" <DW@forum.codecharge> wrote in message
news:63ffc37e50915d@news.codecharge.com...
> I would like to update a date field in a table that has a lastupdated
field for each table in the database with the current date each time a user
makes a change or addition to that table for a particular primary key.
>
> So if a user adds another entry or changes an entry in the "cars" table
for owner "Fred Jones", then another table called "lastupdated", which has a
"Fred Jones" record has the field "lastupdated_cars" updated with todays
date.
>
> Any hints or direction on doing this?
>
> Thanks,
>
> DW
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
Don Safar
|
Posted: 01/07/2004, 12:19 PM |
|
You didn't specify what programming language, but here's a sample from the
ccs help file for ASP and PHP. Just modify the sql to do an update based on
the foreign key. Find this in documentation under Contents, Examples and
Techniques, Programming, Working with Databases, Execute Custom SQL.
ASP
Function Tasks_DataSource_AfterExecuteUpdate()
Dim SQL
Dim Connection
Dim ErrorMessage
SQL = "INSERT INTO report (report_task_id,report_creator) "&_
"VALUES ("& CCToSQL(CCGetFromGet("task_id",0),ccsInteger) &","&
CCToSQL(CCGetUserID(),ccsInteger) &")"
Set Connection = New clsDBConnection1
Connection.Open
Connection.Execute(SQL)
ErrorMessage = CCProcessError(Connection)
Connection.Close
Set Connection = Nothing
On Error Goto 0
End FunctionPHP
function Tasks_ds_AfterExecuteUpdate() {
$SQL = "INSERT INTO report (report_task_id,report_creator) ".
"VALUES (". CCToSQL(CCGetFromGet("task_id",0),ccsInteger) .",".
CCToSQL(CCGetUserID(),ccsInteger) .")";
$db = new clsDBConnection1();
$db->query($SQL);
unset($db);
}"DW" <DW@forum.codecharge> wrote in message
news:63ffc37e50915d@news.codecharge.com...
> I would like to update a date field in a table that has a lastupdated
field for each table in the database with the current date each time a user
makes a change or addition to that table for a particular primary key.
>
> So if a user adds another entry or changes an entry in the "cars" table
for owner "Fred Jones", then another table called "lastupdated", which has a
"Fred Jones" record has the field "lastupdated_cars" updated with todays
date.
>
> Any hints or direction on doing this?
>
> Thanks,
>
> DW
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
|