Author |
Topic |
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
modifichicci
Average Member
Italy
787 Posts |
Posted - 23 April 2008 : 14:47:03
|
Well, to bypass the problem I have tryed this solution:
instead of ruirib's query, i have put strUpLastPost = Reply_Autore DataUltimoPost = getultimopost(strUpLastPost)
and created the function
function getultimopost(strUpLastPost)
strSql = "SELECT MAX(T_DATE) AS T_VALUE FROM " & strTablePrefix & "TOPICS WHERE T_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostT = rs("T_VALUE")
else
DataUltimoPostT = ""
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(R_DATE) AS T_VALUE FROM " & strTablePrefix & "REPLY WHERE R_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostR = rs("T_VALUE")
else
DataUltimoPostR = ""
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(R_DATE) AS T_VALUE FROM " & strTablePrefix & "A_REPLY WHERE R_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostRA = rs("T_VALUE")
else
DataUltimoPostRA = ""
end if
rs.close
set rs = nothing
strSql = "SELECT MAX(T_DATE) AS T_VALUE FROM " & strTablePrefix & "A_TOPICS WHERE T_AUTHOR = " & strUpLastPost
set rs = my_Conn.Execute (strSql)
if not(rs.eof or rs.bof) then
DataUltimoPostTA = rs("T_VALUE")
else
DataUltimoPostTA = ""
end if
rs.close
set rs = nothing
if DataUltimoPostT > DataUltimoPostR then
DUpost = DataUltimoPostT
else
DUpost = DataUltimoPostR
end if
if DataUltimoPostTA > DataUltimoPostRA then
DUpostA = DataUltimoPostTA
else
DUpostA = DataUltimoPostRA
end if
if DUpost > DUpostA then
getultimopost = DUpost
else
getultimopost = DUpostA
end if
end function
no error now.. but.. it worked once with admin and then it get a null value for last post date.. I think there is a logical error in my routine, but i cannot find it and maybe there is a better way to find the max value of four, but I am a surgeon and this is a pure hobby, so if someone can give me some advices he is welcome.. < |
Ernia e Laparocele Forum di Ernia e Laparocele Acces - MySql Migration Tutorial Adamantine forum |
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 23 April 2008 : 15:26:27
|
You will need to test for Null value, since if the user has no posts, max(t_Date) will return a null value. So, test for NULL and if the date is null, set the value for the last post date to ''.< |
Snitz 3.4 Readme | Like the support? Support Snitz too |
|
|
modifichicci
Average Member
Italy
787 Posts |
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
modifichicci
Average Member
Italy
787 Posts |
Posted - 23 April 2008 : 16:35:42
|
I have checked the dates with if DataUltimoPostR > DataUltimoPostRA then response.write "DataUltimoPostR" & DataUltimoPostR else response.write "Dati non corrispondenti" end if response.write "DataUltimoPostT" & DataUltimoPostT response.write "DataUltimoPostRA" & DataUltimoPostRA response.write "DataUltimoPostTA" & DataUltimoPostTA
and dates are selected correctly, and when there is no reply or topics from the author the value is null. But the if statement if DataUltimoPostR > DataUltimoPostRA then with DataUltimoPostR = 20080423223022 and DataUltimoPostRA = "" isn't verify and I get always "Dati non corrispondenti" near the goal but so far..
< |
Ernia e Laparocele Forum di Ernia e Laparocele Acces - MySql Migration Tutorial Adamantine forum |
Edited by - modifichicci on 23 April 2008 16:36:34 |
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
modifichicci
Average Member
Italy
787 Posts |
Posted - 25 April 2008 : 05:30:18
|
I think I have solved: here is the new pop_delete.asp
pop_delete.asp
I have changed the function to:
and changed the Ruirib routine to
strUpLastPost = Reply_Autore ' or Topic etc in different section
DataUltimoPost = getultimopost(strUpLastPost)
strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " SET M_LASTPOSTDATE = '" & DataUltimoPost & "'"
strSql = strSql & " WHERE MEMBER_ID = " & strUpLastPost
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
If someone knows how to optimize the function, he is welcome.< |
Ernia e Laparocele Forum di Ernia e Laparocele Acces - MySql Migration Tutorial Adamantine forum |
|
|
natty
Starting Member
United States
31 Posts |
|
Topic |
|