Add or replace records from a file.
Namespace: NetricsServerInterface
Assembly: NetricsServerInterface (in NetricsServerInterface.dll)
Syntax
| Visual Basic (Declaration) |
|---|
| Public Function addRecsFromFile( _ ByVal tblName As String, _ ByVal replaceNotAdd As Boolean, _ ByVal fileDef As NetricsRecFile _ ) As NetricsTableStats |
| C# |
|---|
| public NetricsTableStats addRecsFromFile( string tblName, bool replaceNotAdd, NetricsRecFile fileDef ) |
| C++ |
|---|
| public: NetricsTableStats addRecsFromFile( String tblName, bool replaceNotAdd, NetricsRecFile fileDef ) sealed |
| J# |
|---|
| public NetricsTableStats addRecsFromFile( string tblName, bool replaceNotAdd, NetricsRecFile fileDef ) |
| JScript |
|---|
| public
function addRecsFromFile( tblName : String, replaceNotAdd : bool, fileDef : NetricsRecFile ) : NetricsTableStats |
Parameters
- tblName
- Defines table records are added to or replaced in.
- replaceNotAdd
- If true this replaces existing records, if false it adds new records.
- fileDef
- Defines the name and format of the file Containing the records.
Return Value
The statistics for the table after the add or replace operations were performed.
Exceptions
| Exception Type | Condition |
|---|---|
| NetricsException | If the server indicates that an error has occured (Possible errors - same as recadd) |
Example
This sample code shows how to add records from a file to an existing table starting with a key of 100. The tblLock parameter is null indicating the table will not be locked.
The TIBCO® Patterns - Search Server is running on the localhost listening to port 5051.
See NetricsRecFile for a definition of it's associated parameters.
Copy Code
| |
|---|---|
using System;
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);
NetricsRecFile netricsRecFile = null;
String table = "names";
String encoding = "latin1";
String file = "c:\\temp\\names.csv";
bool doMaxWork = true;
bool leadingKey = false;
int initialKey = 20000;
bool fieldNamesFirst = false;
bool replaceNotAdd = false;
netricsRecFile = new NetricsRecFile(file, encoding, doMaxWork, leadingKey, initialKey, fieldNamesFirst, false, -1, null);
NetricsTableStats xresponse = si.addRecsFromFile(table, replaceNotAdd, null, netricsRecFile);
Console.Write(xresponse.getName() + ": " + xresponse.getNumRecs().ToString() + " records in table.\n");
}
catch (NetricsException e)
{
Console.Write(e.getErrorDescription() + "\n");
}
}
}
| |