Add records to a table.


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

Syntax

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

Parameters

tblName
The name of the table that the records will be added to
src
The record source for those records which will be added
doMaxWork
Continue on error - adds those records which do not already exist
estNumRecs
The estimated number of records in the record source.This is used by the server to determine the most efficient loading method. It need not be exact.

Return Value

The stats for the table after the records have been added

Exceptions

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

Example

This sample shows how to add records to 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 added
                       String file = "c:\\temp\\names.csv";
                       // Target ibi™ Patterns - Search table
                       String table = "names";
                       // Estimated number of records to be added or -1 if not known
                       int estNumRecs = -1;
                       NetricsTableStats response = null;
                       // Set doMaxWork to true if you want to ignore format errors on input file and continue
                       bool doMaxWork=false;
                       // Set the NetricsRecFile to recadd without key from file.
                       NetricsRecFile netricsRecFile = new NetricsRecFile(file);
                       // Set the initalKey for the records being added to 20000
                       netricsRecFile.setInitialKey(20000);
                       // set the record source for the recadd method
                       NetricsCSVRecSrc src = new NetricsCSVRecSrc(netricsRecFile);
                       // Do the recadd
                       response = si.recadd(table, src, doMaxWork, estNumRecs); 
                       Console.WriteLine("Records added: Number of records in table "+table+ " is "+ response.getNumRecs()+".");
                   }
                   catch (NetricsException e)
                   {
                       Console.Write(e.getErrorDescription() + "\n");
                   }
                 }
              }
            

See Also