void InsertFindingsIntoDB_bn ( dbmgr_cs*  dbmgr,   nodelist_bn*  nodes,   const char*  column_names,   const char*  tables,   const char*  options )

Creates a new record in the database dbmgr consisting of the current findings.

This function corresponds to the basic SQL1 INSERT statement:

    INSERT INTO table1 (col1,col2,...,colN) VALUES (value1,value2,...,valueN) .

nodes represents the nodes (node1,...,nodeN) whose current finding values (value1,...,valueN) will be inserted.

column_names is a comma-delimited list of database column names. The names in this list must be in the exact same order as their corresponding nodes in nodes. If column_names is NULL, then for each Node, Netica will use that Node's title (or, if the title is not defined, then the name) as the corresponding column name.

tables is a comma-delimited list of database table names. If the database has only one conventional (non-system) table, then you can submit NULL for this parameter and Netica will find the implied table for you.

Thus, for the SQL command   INSERT INTO table1 (col1,col2,...,colN) VALUES (value1,value2,...,valueN), tables should be "table1"; column_names should be "col1,col2,...,colN"; and nodes should be a list of nodes in the order node1, node2, ..., nodeN.

Pass NULL for options; it is only for future expansion.

What value is inserted? If a node does not have a value then "NULL" is used for the value inserted. For most databases, this has the result of inserting a "Missing Data" value, although check with your database vendor regarding this (e.g., MS-ACCESS-2000 generally follows this rule but will insert "false" in a boolean field, instead of "Missing Data"). Otherwise, if a node does have a value, then the behavior varies, depending on whether the node is discrete or continuous. For discrete nodes, if that node has a state title, then that state title is inserted. If it does not have a title, but it has a name, then the name is inserted. And if it has neither title nor name, then the numeric state index (0... nStates-1) is inserted. For continuous nodes, the number inserted is the same as that returned by GetNodeValueEntered_bn.

If there is a problem with the SQL INSERT command, an error will be generated explaining the nature of the problem.

1 SQL is a standard query language for accessing databases. To properly use this function, you should have basic familiarity with the SQL INSERT statement.


Versions 2.26 and later have this function. In versions previous to 3.05, this function was named FindingsToDB_bn.

See also:

NewDBManager_cs    Creates the dbmgr_cs
ExecuteDBSql_cs    Execute an arbitrary SQL command
AddDBCasesToCaseset_cs    Retrieve a set of cases using SQL SELECT
AddNodesFromDB_bn    Add nodes to a net using cases from SQL SELECT


dbmgr_cs *dbmgr = NewDBManager_cs (
   "driver={Microsoft Access Driver (*.mdb)}; dbq=.\\myDB.mdb;UID=dba1;", "pooling", env);
net_bn*  net           = NewNet_bn ("odbcTestNet", env);
node_bn* sexNode       = NewNode_bn ("sex",       2, net );
node_bn* heightNode    = NewNode_bn ("height",    0, net );
node_bn* ownsHouseNode = NewNode_bn ("ownsHouse", 2, net );
node_bn* numDogsNode   = NewNode_bn ("numDogs",   0, net );
nodelist_bn* nodes;
SetNodeStateName_bn (sexNode, 0, "M");
SetNodeStateName_bn (sexNode, 1, "F");
nodes = (nodelist_bn*) GetNetNodes_bn (net);
EnterFinding_bn (sexNode, GetStateNamed_bn ("M",sexNode));
EnterNodeValue_bn ( heightNode, 2.222 );
EnterFinding_bn (ownsHouseNode,1);
//Insert the net's current findings into Table1
InsertFindingsIntoDB_bn (dbmgr, 
                         "Sex, Height, \"Owns a house\", \"Number of dogs\"",