Replace records in a table.


Namespace: NetricsServerInterface
Assembly: NetricsServerInterface (in NetricsServerInterface.dll)

Syntax

Visual Basic (Declaration)
Public Function recreplace( _ 
   ByVal tblName As String,  _ 
   ByVal src As NetricsTableRecSrc,  _ 
   ByVal doMaxWork As Boolean _ 
) As NetricsTableStats
C#
public NetricsTableStats recreplace(
   string tblName,
   NetricsTableRecSrc src,
   bool doMaxWork
)
C++
public:
 NetricsTableStats recreplace(
   String tblName,
   NetricsTableRecSrc src,
   bool doMaxWork
) sealed 
J#
public NetricsTableStats recreplace(
   string tblName,
   NetricsTableRecSrc src,
   bool doMaxWork
)
JScript
public  function recreplace(
   tblName : String,
   src : NetricsTableRecSrc,
   doMaxWork : bool
) : NetricsTableStats

Parameters

tblName
The name of the table in which records will be replaced.
src
The record source for those records which will be replaced
doMaxWork
Continue on error - replaces those records which do exist

Return Value

The stats for the table after the records have been replaced

Exceptions

Exception TypeCondition
NetricsException If the server indicates an error occured (Possible errors - TBLNOTFOUND, DUPRECKEYS, EXPECTTBLDESC, EXPECTLIST, EXPECTRECORD, FIELDLENSUM, NOTBLDESC, NORECKEY, NOSRCHTXT, NUMFIELDS, RECNOTFOUND, UPDPARAM, SHUTDOWN)

Example

This sample shows how to replace records in a table from a csv input file.

 Copy Code
            using NetricsServerInterface;  
            class MyClass 
              {
                private static NetricsServerInterface.NetricsServerInterface si = null;     
                public static void Main() 
                 {
                   try
                   {
                       String host = "localhost";
                       int port = 5051;
                       si = new NetricsServerInterface.NetricsServerInterface(host, port);
                       // CSV input file of records to be replaced
                       String file = "c:\\temp\\names.csv";
                       // Target ibi™ Patterns - Search table
                       String table = "names";
                       NetricsTableStats response = null;
                       // Set doMaxWork to true if you want to ignore format errors on input file and continue
                       bool doMaxWork = false;
                       // Load .csv file.
                       // CSV is without a key in file.
                       NetricsRecFile netricsRecFile = new NetricsRecFile(file);
                       // Set the initalKey for the records being replaced. Key is incremented by 1 for each record in file.
                       netricsRecFile.setInitialKey(1);
                       // First record in csv file is a data record and not a header so setFieldNamesFirst 
                       // should be set to false
                       netricsRecFile.setFieldNamesFirst(false);
                       // set the record source for the recadd method
                       NetricsCSVRecSrc src = new NetricsCSVRecSrc(netricsRecFile);
                       response = si.recreplace(table, src, doMaxWork);
                       Console.WriteLine("Records replace: Number of records in table " + table + " is " + response.getNumRecs() + ".");
                   }
                   catch (NetricsException e)
                   {
                       Console.Write(e.getErrorDescription() + "\n");
                   }
                 }
              }
            

See Also