Cyril
|
| Posted: 03/19/2002, 7:34 AM |
|
How can I insert the current date/time to the date_posted field if I am using Oracle database?
|
|
|
 |
Ken Hardwick
|
| Posted: 03/19/2002, 4:39 PM |
|
Cyril,
I've been working with Oracle and CC for last year. Add the following two functions to your global functions. Then, use your date fields just like any other database.
For your specific example, in your before update and/or before insert events.
Just set your field to current date/time..like
fldDate_Posted = now
Note that this will use the data on your web server or maybe your workstation not your oracle server. If you want to use your oracle server, you would need to do it some other way. In a straight SQL it would be "date_Posted = sysdate"
And if you wanted/needed the oracle date, you would need to modify the ToSQL function...like add..
if Value = "sysdate" then
ToSQL = "sysdate"
else
....all the other orignal if statements etc...
end if
Hope this helps.....
Ken Hardwick
Function ToSQL(Value, sType)
Dim Param : Param = Value
if Param = "" then
ToSQL = "Null"
else
if sType = "Number" then
ToSQL = replace(CDbl(Param), ",", ".")
else
if sType = "Date" then
ToSQL = OracleDate(Param)
else
ToSQL = "'" & Replace(Param, "'", "''") & "'"
end if
end if
end if
end function
Function OracleDate(newDate)
'This function convert date to oracle date format
Dim dtTemp
dim dtTime
If newDate <> "" Then
If Day(newDate) < 10 Then
dtTemp = "0"
End If
dtTemp = dtTemp & Day(newDate) & "-" & UCase(Trim(MonthName(Month(newDate),4))) & "-" & Right(Year(newDate),4)
End If
dtTime = FormatDateTime(newDate,4) & ":" & right("0"& second(newdate),2)
dtTemp = "To_date('" & dttemp & ":" & dttime & "','DD-MON-YYYY hh24:mi:ss')"
OracleDate = dtTemp
End Function
|
|
|
 |
|