2016-07-20 6 views
0

誰でもこのVBScriptが何をしているのか理解できます。私はWhereClauseに迷子@Daveが述べ同様VBScriptコードの説明

If CVs = "," or CVs = ",," Then 
    ExistingSupplierCVs = 0 
Else 
    Set CVRecords = Ext.CreateAppRecordList(ActivityTableId) 
    WhereClause = Left(CVs, Len(CVs)-1) 
    WhereClause = Right(WhereClause, Len(WhereClause)-1) 
    WhereClause = "TS_ID in (" & WhereClause & ") and TS_SUPPLIER = " &  Supplier 

    If Not CVRecords.ReadWithWhere(WhereClause) then 
     Call Ext.LogErrorMsg("TeamScript Error : Cannot find " & QUOTE & WhereClause & QUOTE & " in table " & QUOTE & "USR_ACTIVITY" & QUOTE) 
     Exit Sub 
    End If 

    ExistingSupplierCVs = CVRecords.Length() 
End If 
+0

あなたはそれを説明しようとし、あなたが正しいかどうかを教えてくれます。 – Lankymart

+0

WhereClause =左から..(CVを返す、(CVの長さ)-1) –

答えて

0

ベストの推測では...以下のように

If CVs = "," or CVs = ",," Then 
    ExistingSupplierCVs = 0 ' if the string is empty advise that the number of CVs is zero 
Else 
    Set CVRecords = Ext.CreateAppRecordList(ActivityTableId) ' extract a list of CVRecords 
    WhereClause = Left(CVs, Len(CVs)-1) ' strip the last char from this string 
    WhereClause = Right(WhereClause, Len(WhereClause)-1) ' strip the first char from this string 
    WhereClause = "TS_ID in (" & WhereClause & ") and TS_SUPPLIER = " &  Supplier ' insert the values into (presumably) a SQL query 

    If Not CVRecords.ReadWithWhere(WhereClause) then ' if executing the query returns false 
     Call Ext.LogErrorMsg("TeamScript Error : Cannot find " & QUOTE & WhereClause & QUOTE & " in table " & QUOTE & "USR_ACTIVITY" & QUOTE) 'report an error and exit the subroutine. 
     Exit Sub 
    End If 

    ExistingSupplierCVs = CVRecords.Length() ' return the number of records from the query 
End If 
1

あるビット:彼らはCVs文字列から最初と最後の文字を削除しています。

は簡単な方法は、あなたがこのような3つのすべての行組み合わせることができMid

WhereClause = Mid(CVs, 2, Len(CVs) - 2)

を使用することです:これはセレナビジネスマネージャ作曲言語に非常に典型的である

WhereClause = "TS_ID in (" & Mid(CVs, 2, Len(CVs) - 2) & ") and TS_SUPPLIER = " & Supplier 
0

を - AppScript。

共有したコードは、複数の関係フィールドのレコード数を数え、その値をフィールドに入力することです。典型的な空のマルチリレーショナルフィールドは、この ",, ,,"のようになり、このMRフィールドが指しているフィールドのIDを示す数字と共に、 "、1,34"のようなものになります。

作成されているwhere句は、MRフィールドから最初と最後のカンマを削除してからIdを問い合せるだけです。

ここにまだ疑問がある場合はお知らせください。