0

テキストフィールドを更新しようとしています。データを別の列に移動し、長すぎるため切り捨てます。

更新ステートメントは次のようになります。(編集済み)

UPDATE Feuil1 SET [Occupant 2] = SWITCH
(
[Occupant 2] IS NOT NULL, [Occupant 3],
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 3), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 4), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 5), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 6), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 7), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
     (LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 2), '',
     (LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 1), '',
     [Occupant 1] LIKE '* & *', mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
     [Occupant 1] LIKE '* ET *', mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
     (LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 0), ''
), [Occupant 1] = SWITCH
(
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 3), mid([Occupant 1],1,InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," ")),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 4), mid([Occupant 1],1,InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," ")),
[Occupant 1] LIKE '* & *', (replace([Occupant 1], ' & ' & mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," ")),InStr(InStr(2,[Occupant 1]," ")), '')),
[Occupant 1] LIKE '* ET *', (replace([Occupant 1], ' & ' & mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," ")),InStr(InStr(2,[Occupant 1]," ")), ''))
)
WHERE [Occupant 1] IS NOT NULL

変換タイプのエラーが常に発生しますが、理由がわかりません。独自の変更されたデータでテキスト フィールドを更新しています。関連する列はすべてテキストです。

Val()、Cstr() 関数を使用しようとしましたが、同じ結果が得られました。

追加情報: 一部のデータが処理されているようですが、理由がわかりません。

手がかりはありますか?

4

1 に答える 1

2

ステートメントの最初に、次の行があります。

UPDATE Feuil1 SET [Occupant 2] = SWITCH
(
[Occupant 2] IS NOT NULL, [Occupant 3] = [Occupant 2],

ここで言っているのは、[Occupant 2]がNULLでない場合、[Occupant2]を[Occupant3] = [Occupant 2]のブール結果True(つまり、 False)に等しく設定するということです。私はあなたがそれを次のいずれかに変更したいと思っていると思います:

UPDATE Feuil1 SET [Occupant 2] = SWITCH
(
[Occupant 2] IS NOT NULL, [Occupant 3],

または、より可能性が高い:

UPDATE Feuil1 SET [Occupant 2] = SWITCH
(
[Occupant 2] IS NOT NULL, [Occupant 2],
于 2013-01-24T16:03:09.317 に答える