Bonjour,
J'ai mis en place un script qui test les guillemets sur toutes les colonnes et pour chaque ligne.
Afin de terminer mon test, je souhaite mettre une colonne en output du script afin de mettre 1 si je trouve au moins 1 guillemet sur la ligne testée sinon 0.
Le soucis c'est que je n'arrive pas à ecrire le resultat de mon test dans une colonne.
Le script en entier :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 // This script adjusts the value of all string fields using System; using System.Data; using Microsoft.SqlServer.Dts.Pipeline.Wrapper; using Microsoft.SqlServer.Dts.Runtime.Wrapper; using System.Windows.Forms; using System.Reflection; [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute] public class ScriptMain : UserComponent { int var1; // Method that will be started for each record in you dataflow public override void Input0_ProcessInputRow(Input0Buffer Row) { // Use Reflection to loop through all the properties of Row: // Example: // Row.Field1 (String) // Row.Field1_IsNull (Boolean) // Row.Field2 (String) // Row.Field2_IsNull (Boolean) foreach (PropertyInfo p in Row.GetType().GetProperties()) { // Do something for all string properties: Row.Field1, Row.Field2, etc. try //check error when null { if (object.ReferenceEquals(p.PropertyType, typeof(string))) { // Use a method to set the value of each String type property // Make sure the length of the new value not exceed the column size p.SetValue(Row, DoSomething(p.GetValue(Row, null).ToString()), null); //ecriture dans une colonne output Row.checkcolumn.Equals(var1); } } catch (NullReferenceException e) { } } } // New function that you can adjust to suit your needs public string DoSomething(string ValueOfProperty) { if (ValueOfProperty.Contains("\"")) { Variables.var1 = 1; } else { Variables.var1 = 0; } return ValueOfProperty; } }
Merci par avance.





Répondre avec citation
Partager