summaryrefslogtreecommitdiff
path: root/docs/gsg/C/CoreCursorUsage.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/gsg/C/CoreCursorUsage.html')
-rw-r--r--docs/gsg/C/CoreCursorUsage.html32
1 files changed, 21 insertions, 11 deletions
diff --git a/docs/gsg/C/CoreCursorUsage.html b/docs/gsg/C/CoreCursorUsage.html
index 0d681396..a04474d2 100644
--- a/docs/gsg/C/CoreCursorUsage.html
+++ b/docs/gsg/C/CoreCursorUsage.html
@@ -14,7 +14,7 @@
<body>
<div xmlns="" class="navheader">
<div class="libver">
- <p>Library Version 11.2.5.3</p>
+ <p>Library Version 12.1.6.1</p>
</div>
<table width="100%" summary="Navigation header">
<tr>
@@ -94,7 +94,7 @@
Remember that you can find the complete implementation of this application
in:
</p>
- <pre class="programlisting"><span class="emphasis"><em>DB_INSTALL</em></span>/examples_c/getting_started</pre>
+ <pre class="programlisting"><span class="emphasis"><em>DB_INSTALL</em></span>/examples/c/getting_started</pre>
<p>
where <code class="literal"><span class="emphasis"><em>DB_INSTALL</em></span></code> is the location where you
placed your DB distribution.
@@ -126,7 +126,12 @@ int show_vendor_record(char *, DB *); </pre>
</p>
<a id="c_cursor11"></a>
<pre class="programlisting">/*
- * Displays all inventory items and the associated vendor record.
+ * Searches for an inventory item based on that item's name. The search is
+ * performed using the item name secondary database. Displays all
+ * inventory items that use the specified name, as well as the vendor
+ * associated with that inventory item.
+ *
+ * If no item name is provided, then all inventory items are displayed.
*/
int
main(int argc, char *argv[])
@@ -176,7 +181,7 @@ main(int argc, char *argv[])
<a id="c_cursor12"></a>
<pre class="programlisting">int show_all_records(STOCK_DBS *my_stock)
{
- DBC *cursorp;
+ DBC *inventory_cursorp;
DBT key, data;
char *the_vendor;
int exit_value, ret;
@@ -187,7 +192,7 @@ main(int argc, char *argv[])
/* Get a cursor to the itemname db */
my_stock-&gt;inventory_dbp-&gt;cursor(my_stock-&gt;inventory_dbp, NULL,
- &amp;cursorp, 0);
+ &amp;inventory_cursorp, 0);
/*
* Iterate over the inventory database, from the first record
@@ -195,7 +200,7 @@ main(int argc, char *argv[])
*/
exit_value = 0;
while ((ret =
- cursorp-&gt;get(cursorp, &amp;key, &amp;data, DB_NEXT))
+ inventory_cursorp-&gt;get(inventory_cursorp, &amp;key, &amp;data, DB_NEXT))
== 0)
{
the_vendor = show_inventory_item(data.data);
@@ -207,7 +212,7 @@ main(int argc, char *argv[])
}
/* Close the cursor */
- cursorp-&gt;close(cursorp);
+ inventory_cursorp-&gt;close(inventory_cursorp);
return(exit_value);
} </pre>
<p>
@@ -224,13 +229,18 @@ main(int argc, char *argv[])
</p>
<a id="c_cursor13"></a>
<pre class="programlisting">/*
- * Shows an inventory item.
+ * Shows an inventory item. How we retrieve the inventory
+ * item values from the provided buffer is strictly dependent
+ * on the order that those items were originally stored in the
+ * DBT. See load_inventory_database in example_database_load
+ * for how this was done.
*/
char *
show_inventory_item(void *vBuf)
{
float price;
- int buf_pos, quantity;
+ int quantity;
+ size_t buf_pos;
char *category, *name, *sku, *vendor_name;
char *buf = (char *)vBuf;
@@ -298,7 +308,7 @@ show_vendor_record(char *vendor_name, DB *vendor_dbp)
/* Set the search key to the vendor's name */
key.data = vendor_name;
- key.size = strlen(vendor_name) + 1;
+ key.size = (u_int32_t)strlen(vendor_name) + 1;
/*
* Make sure we use the memory we set aside for the VENDOR
@@ -312,7 +322,7 @@ show_vendor_record(char *vendor_name, DB *vendor_dbp)
data.flags = DB_DBT_USERMEM;
/* Get the record */
- ret = vendor_dbp-&gt;get(vendor_dbp, 0, &amp;key, &amp;data, 0);
+ ret = vendor_dbp-&gt;get(vendor_dbp, NULL, &amp;key, &amp;data, 0);
if (ret != 0) {
vendor_dbp-&gt;err(vendor_dbp, ret,
"Error searching for vendor: '%s'", vendor_name);