Hello all
I got a Problem when I try to store Data from a Flatfile to a DB.
The following Error appears in the Progress Control:
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_Products_1'. Cannot insert duplicate key in object 'dbo.Products'.".
I have a Flat File Source, and would like to store the needed records in a DB.
In Column 0 in the Flatfile I have multiple Entries with equal Values.
In the DB this Column is set as Primary Key and can only have one Record with the same Value in this Column.
How can I read out (or store) only one Record with the same Value from the Flatfile to store it in the DB
How can I check if there is a Record from the Flatfile in the DB with the same value in the Primary Key
How can I change any of the remaining Columns with different Values in the DB to match with the Flatfile
Thanks in advance for any answer
Chaepp

Import dedicated Records from a Flatfile to a DB
mlcprs
Hello,
Thanks for your quick answer.
The DB Table is empty and I like to load the data from the Flatfile....
Then I get the error. I tried to go with Lookup, but I have still the same problem...
Could you give me an idea how to solve the problem
Thanks for an early answer.
Regards
Chaepp
Dawa Tsering
Dim alist As New ArrayList
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
If Not alist.Contains(Row.Name) Then
alist.Add(Row.Name)
Output0Buffer.AddRow()
Output0Buffer.NameOut = Row.Name
End If
End Sub
the Name property of Row comes from the flat file as the Input column
NameOut of Outpu0Buffer is the Script Output column
kenlefeb
btw, by "ole db" i meant "ole db command". sorry about the confusion.
schmack
AlistairSKing
I like to see how this one pans out, as i cannot see how a Lookup would work. By definition Chaepp is importing to a table where the data does not already exist thus the lookup would fail. He could redirect this 'failure' as his error output, but then all his errors would be cached and thus still fail for the same reason as he would have multiple failures on the same data and thus when the data flow passes into the destination to actually write to his database table, it will still fall over. I could see a Lookup working if it would write each row it did not find to the destination table and thus subsequent finds , ie PK violations, could be re-directed, but only if the table is being updated in real time from the lookup which it does not do. I'm thinking a Script component here, not lookup.
Dave
curt2go
Sorry, I'm a beginner.
What do you mean with 'ole db transformation' The Ole DB Command
Regards
Chaepp
MillBear
Benin
Hi
Thank you very much for your help.
I have found another solution:
I simply use the Aggregate function and it works perfect....
Regards
Chaepp