在 FileMaker Pro 中修改 ExecuteSQL 语句以允许天数宽限
Modifying an ExecuteSQL statement in FileMaker Pro to allow for day leniency
我正在尝试更改一个长脚本中的语句,该语句将一个变量设置为几个变量完全匹配的结果。现在它是一个精确的日期匹配,如果日期相差 ~2 天,之前或之后,我想让它匹配。当前脚本是:
Let( [
UUID = sqlNameField( EIV_Eiv::A__UUID ; "" ; "" )
; BATCHID = sqlNameField( EIV_Eiv::A_BATCH_ID ; "" ; "" )
; PID = sqlNameField( EIV_Eiv::User_ID ; "" ; "" )
; STARTDATE = sqlNameField( EIV_Eiv::Start date ; "" ; "" )
; EIV = sqlNameTable( EIV_Eiv::A__UUID ; "" )
] ;
ExecuteSQL( "SELECT" & UUID & "," & BATCHID & "FROM" & EIV & "WHERE" & PID & "= ? AND" & STARTDATE & "= ? FETCH FIRST ROW ONLY" ; ¶ ; "" ; EIM_Eim__SELECTED::User_id ; EIM_Eim__SELECTED::Start_date )
)
我尝试将 ExecuteSQL
行修改为:
ExecuteSQL( "SELECT" & UUID & "," & BATCHID & "FROM" & EIV & "WHERE" & PID & "= ? AND" & STARTDATE & "- ? >= -2 AND" & STARTDATE & "- ? <= 2 FETCH FIRST ROW ONLY" ; ¶ ; "" ; EIM_Eim__SELECTED::User_id ; EIM_Eim__SELECTED::Start_date )
没有效果(并且 FMP 不会 return 我能看到的任何类型的错误)。我以正确的方式解决这个问题吗?我是 FMP 脚本的新手,而且我对 SQL.
很业余
我不会尝试直接对 SQL 中的日期列进行数学计算,而是在您传递的 FileMaker 参数中进行计算。 (还有,好像少了一些空格是我加的)
像这样:
ExecuteSQL( "SELECT " & UUID & "," & BATCHID &
" FROM " & EIV &
" WHERE " & PID & " = ? AND " & STARTDATE >= ? AND STARTDATE <= ? FETCH FIRST ROW ONLY" ;
"¶" ; "" ; EIM_Eim__SELECTED::User_id ; EIM_Eim__SELECTED::Start_date - 2;
EIM_Eim__SELECTED::Start_date + 2 )
我正在尝试更改一个长脚本中的语句,该语句将一个变量设置为几个变量完全匹配的结果。现在它是一个精确的日期匹配,如果日期相差 ~2 天,之前或之后,我想让它匹配。当前脚本是:
Let( [
UUID = sqlNameField( EIV_Eiv::A__UUID ; "" ; "" )
; BATCHID = sqlNameField( EIV_Eiv::A_BATCH_ID ; "" ; "" )
; PID = sqlNameField( EIV_Eiv::User_ID ; "" ; "" )
; STARTDATE = sqlNameField( EIV_Eiv::Start date ; "" ; "" )
; EIV = sqlNameTable( EIV_Eiv::A__UUID ; "" )
] ;
ExecuteSQL( "SELECT" & UUID & "," & BATCHID & "FROM" & EIV & "WHERE" & PID & "= ? AND" & STARTDATE & "= ? FETCH FIRST ROW ONLY" ; ¶ ; "" ; EIM_Eim__SELECTED::User_id ; EIM_Eim__SELECTED::Start_date )
)
我尝试将 ExecuteSQL
行修改为:
ExecuteSQL( "SELECT" & UUID & "," & BATCHID & "FROM" & EIV & "WHERE" & PID & "= ? AND" & STARTDATE & "- ? >= -2 AND" & STARTDATE & "- ? <= 2 FETCH FIRST ROW ONLY" ; ¶ ; "" ; EIM_Eim__SELECTED::User_id ; EIM_Eim__SELECTED::Start_date )
没有效果(并且 FMP 不会 return 我能看到的任何类型的错误)。我以正确的方式解决这个问题吗?我是 FMP 脚本的新手,而且我对 SQL.
很业余我不会尝试直接对 SQL 中的日期列进行数学计算,而是在您传递的 FileMaker 参数中进行计算。 (还有,好像少了一些空格是我加的)
像这样:
ExecuteSQL( "SELECT " & UUID & "," & BATCHID &
" FROM " & EIV &
" WHERE " & PID & " = ? AND " & STARTDATE >= ? AND STARTDATE <= ? FETCH FIRST ROW ONLY" ;
"¶" ; "" ; EIM_Eim__SELECTED::User_id ; EIM_Eim__SELECTED::Start_date - 2;
EIM_Eim__SELECTED::Start_date + 2 )