Enterprise Architect 17.1Pro Cloud Server 6.1
Repository.Execute ("INSERT INTO t_snapshot SnapshotID, SeriesID, Position, SnapshotName, Notes, Style, ElementID, ElementType, BinContent1, BinContent2 VALUES ('L0', 'LOG', ... )");
Hello qwerty,one more question, does the "INSERT INTO" command insert duplicates if the entry allready exists? If this is the case how can I check whether the record allready exits?many thanks in advance!cheersManfred
private void loadAuditLogs(EA.Repository Repository, string logFileName) { var doc = XDocument.Load(logFileName); foreach (var childElem in doc.XPathSelectElements("//Row")) { string SnapshotID = childElem.Element("SnapshotID").Value; string SeriesID = childElem.Element("SeriesID").Value; string Position = childElem.Element("Position").Value; string SnapshotName = childElem.Element("SnapshotName").Value; string Notes = childElem.Element("Notes").Value; string Style = childElem.Element("Style").Value; string ElementID = childElem.Element("ElementID").Value; string ElementType = childElem.Element("ElementType").Value; string BinContent1 = childElem.Element("BinContent1").Value; string BinContent2 = childElem.Element("BinContent2").Value; string query = "INSERT INTO t_snapshot (SnapshotID, SeriesID, Position, SnapshotName, Notes, Style, ElementID, ElementType, BinContent1, BinContent2) VALUES ("+ "'" + SnapshotID + "', "+ // Text "'" + SeriesID + "', "+ // Text "" + Position + ", "+ // Numeric "'" + SnapshotName + "', "+ // Text "'" + Notes + "', "+ // Memo "'" + Style + "', "+ // Text "'" + ElementID + "', "+ // Text "'" + ElementType + "', "+ // Text "'" + BinContent1 + "', "+ // Ole Object "'" + BinContent2 + "'"+ // Ole Object ");"; // check whether the record already exists string result = Repository.SQLQuery("SELECT * FROM t_snapshot WHERE SnapshotID = \"" + SnapshotID + "\"" ); var resultDoc = XDocument.Parse( result ); IEnumerable<XElement> list = resultDoc.XPathSelectElements("//Row"); // only insert the record if it is not already presents if ( list.Count() == 0 ) { try { Repository.Execute( query ); } catch { Repository.WriteOutput("System","sql error...",0); } } else { Repository.WriteOutput("System","A record already exists with SnapshotID "+SnapshotID,0); } } }
We use cookies to improve your experience on our website. Rejecting it may weaken protection and affect site loading speed. You can visit our Privacy Policy page for more information and adjust your cookie settings.
Cookies are very small text files that are stored on your computer when you visit a website. We use cookies for a variety of purposes and to enhance your online experience on our website (for example, to remember your account login details).
You can change your preferences and decline certain types of cookies to be stored on your computer while browsing our website. You can also remove any cookies already stored on your computer, but keep in mind that deleting cookies may prevent you from using parts of our website.
These cookies are essential to provide you with services available through our website and to enable you to use certain features of our website. Without these cookies, we cannot provide you certain services on our website.
If you close the banner without making a selection, the 'Accept Minimum' option will be automatically applied to ensure basic functionality of the website.
These cookies are used to collect information to analyze the traffic to our website and how visitors are using our website. For example, these cookies may track things such as how long you spend on the website or the pages you visit which helps us to understand how we can improve our website site for you.
The information collected through these tracking and performance cookies do not identify any individual visitor.
For any queries in relation to our policy on cookies and your choices, please contact us.